pinokiod 5.1.21 → 5.1.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,22 +14,30 @@ class Cuda {
14
14
  )
15
15
  } catch (e) {}
16
16
  }
17
- async patchCudaActivationScript() {
17
+ async stashCompilerVarsScripts() {
18
18
  if (this.kernel.platform !== "win32") {
19
19
  return
20
20
  }
21
- const script = this.kernel.bin.path("miniconda/etc/conda/activate.d/~cuda-nvcc_activate.bat")
22
- let content
23
- try {
24
- content = await fs.promises.readFile(script, "utf8")
25
- } catch (e) {
26
- return
27
- }
28
- const lines = content.split(/\r?\n/)
29
- const filtered = lines.filter((line) => !/(TORCH_CUDA_ARCH_LIST|CUDAARCHS)/i.test(line))
30
- if (filtered.length !== lines.length) {
31
- const eol = content.includes("\r\n") ? "\r\n" : "\n"
32
- await fs.promises.writeFile(script, filtered.join(eol))
21
+ const folder = this.kernel.bin.path("miniconda/etc/conda/activate.d")
22
+ const stash = path.resolve(folder, "pinokio")
23
+ await fs.promises.mkdir(stash, { recursive: true }).catch(() => {})
24
+ const scripts = [
25
+ "vs2019_compiler_vars.bat",
26
+ "vs2022_compiler_vars.bat",
27
+ ]
28
+ for (const script of scripts) {
29
+ const dest = path.resolve(stash, script)
30
+ for (const src of [path.resolve(folder, script), path.resolve(folder, `${script}.disabled`)]) {
31
+ try {
32
+ await fs.promises.rename(src, dest)
33
+ break
34
+ } catch (e) {
35
+ if (e && e.code === "EEXIST") {
36
+ await fs.promises.rm(src).catch(() => {})
37
+ break
38
+ }
39
+ }
40
+ }
33
41
  }
34
42
  }
35
43
  async install(req, ondata) {
@@ -48,18 +56,7 @@ class Cuda {
48
56
  ]
49
57
  }, ondata)
50
58
  await this.restoreCudaActivationScript()
51
- await this.patchCudaActivationScript()
52
- const folder = this.kernel.bin.path("miniconda/etc/conda/activate.d")
53
- let deactivate_list = [
54
- "vs2019_compiler_vars.bat",
55
- "vs2022_compiler_vars.bat",
56
- ]
57
- for(let item of deactivate_list) {
58
- const old_name = path.resolve(folder, item)
59
- const new_name = path.resolve(folder, item + ".disabled")
60
- console.log("rename", { old_name, new_name })
61
- await fs.promises.rename(old_name, new_name)
62
- }
59
+ await this.stashCompilerVarsScripts()
63
60
  } else {
64
61
  await this.kernel.bin.exec({
65
62
  message: [
@@ -87,7 +84,7 @@ class Cuda {
87
84
  if (this.kernel.gpu === "nvidia") {
88
85
  if (this.kernel.platform === 'win32') {
89
86
  await this.restoreCudaActivationScript()
90
- await this.patchCudaActivationScript()
87
+ await this.stashCompilerVarsScripts()
91
88
  if (this.kernel.bin.installed.conda.has("cudnn") && this.kernel.bin.installed.conda.has("cuda") && this.kernel.bin.installed.conda.has("libzlib-wapi")) {
92
89
  let version = this.kernel.bin.installed.conda_versions.cuda
93
90
  if (version) {
package/kernel/shell.js CHANGED
@@ -949,37 +949,43 @@ class Shell {
949
949
  if (params.build) {
950
950
  if (this.platform === "win32") {
951
951
  try {
952
- let vcvars_path = this.kernel.bin.vs_path_env.VCVARSALL_PATH
953
- if (vcvars_path) {
954
- const architecture = os.arch().toLowerCase(); // 'x64', 'ia32' (32-bit), etc.
955
- const armArchitecture = process.arch.toLowerCase(); // For ARM-based architectures (on Windows), process.arch might be 'arm64', 'arm', etc.
956
-
957
- // Map architectures to vcvarsall.bat argument
958
- let arg
959
- if (architecture === 'x64' || armArchitecture === 'arm64') {
960
- //arg = 'amd64'; // Native 64-bit architecture
961
- arg = 'x64';
962
- } else if (architecture === 'ia32' || armArchitecture === 'arm') {
963
- arg = 'x86'; // Native 32-bit architecture
964
- } else if (armArchitecture === 'x86_arm64') {
965
- arg = 'x86_arm64'; // ARM64 on x86
966
- } else if (armArchitecture === 'x86_arm') {
967
- arg = 'x86_arm'; // ARM on x86
968
- } else if (armArchitecture === 'amd64_arm64') {
969
- arg = 'amd64_arm64'; // ARM64 on x64
970
- } else if (armArchitecture === 'amd64_arm') {
971
- arg = 'amd64_arm'; // ARM on x64
972
- } else {
973
- console.log(`Unsupported arch: os.arch()=${architecture}, process.arch=${armArchitecture}`)
974
- }
975
-
976
- if (arg) {
977
- //conda_activation.push(`CALL "${vcvars_path}" ${arg} > nul 2>&1`)
978
- conda_activation.push(`CALL "${vcvars_path}" ${arg}`)
979
- }
952
+ const vcvars_path = this.kernel.bin.vs_path_env && this.kernel.bin.vs_path_env.VCVARSALL_PATH
953
+ const architecture = os.arch().toLowerCase(); // 'x64', 'ia32' (32-bit), etc.
954
+ const armArchitecture = process.arch.toLowerCase(); // For ARM-based architectures (on Windows), process.arch might be 'arm64', 'arm', etc.
955
+
956
+ // Map architectures to vcvarsall.bat argument
957
+ let arg
958
+ if (architecture === 'x64' || armArchitecture === 'arm64') {
959
+ //arg = 'amd64'; // Native 64-bit architecture
960
+ arg = 'x64';
961
+ } else if (architecture === 'ia32' || armArchitecture === 'arm') {
962
+ arg = 'x86'; // Native 32-bit architecture
963
+ } else if (armArchitecture === 'x86_arm64') {
964
+ arg = 'x86_arm64'; // ARM64 on x86
965
+ } else if (armArchitecture === 'x86_arm') {
966
+ arg = 'x86_arm'; // ARM on x86
967
+ } else if (armArchitecture === 'amd64_arm64') {
968
+ arg = 'amd64_arm64'; // ARM64 on x64
969
+ } else if (armArchitecture === 'amd64_arm') {
970
+ arg = 'amd64_arm'; // ARM on x64
980
971
  } else {
981
- // console.log('vc vars env doesnt exist')
972
+ console.log(`Unsupported arch: os.arch()=${architecture}, process.arch=${armArchitecture}`)
973
+ }
974
+
975
+ const compiler_log = '"%TEMP%\\pinokio-vs.log"'
976
+ const compiler_cmd = [
977
+ `if exist "%CONDA_PREFIX%\\etc\\conda\\activate.d\\pinokio\\vs2019_compiler_vars.bat" (call "%CONDA_PREFIX%\\etc\\conda\\activate.d\\pinokio\\vs2019_compiler_vars.bat" > ${compiler_log} 2>&1)`,
978
+ `else if exist "%CONDA_PREFIX%\\etc\\conda\\activate.d\\pinokio\\vs2022_compiler_vars.bat" (call "%CONDA_PREFIX%\\etc\\conda\\activate.d\\pinokio\\vs2022_compiler_vars.bat" > ${compiler_log} 2>&1)`,
979
+ `else if exist "%CONDA_PREFIX%\\etc\\conda\\activate.d\\vs2019_compiler_vars.bat" (call "%CONDA_PREFIX%\\etc\\conda\\activate.d\\vs2019_compiler_vars.bat" > ${compiler_log} 2>&1)`,
980
+ `else if exist "%CONDA_PREFIX%\\etc\\conda\\activate.d\\vs2022_compiler_vars.bat" (call "%CONDA_PREFIX%\\etc\\conda\\activate.d\\vs2022_compiler_vars.bat" > ${compiler_log} 2>&1)`,
981
+ ]
982
+ if (vcvars_path && arg) {
983
+ compiler_cmd.push(`else if exist "${vcvars_path}" (CALL "${vcvars_path}" ${arg} > ${compiler_log} 2>&1)`)
982
984
  }
985
+ conda_activation.push(compiler_cmd.join(" "))
986
+ conda_activation.push("@echo off")
987
+ conda_activation.push("set TORCH_CUDA_ARCH_LIST=")
988
+ conda_activation.push("set CUDAARCHS=")
983
989
  } catch (e) {
984
990
  console.log('vc vars setup', e)
985
991
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "5.1.21",
3
+ "version": "5.1.23",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {