pinokiod 5.1.21 → 5.1.22
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.
- package/kernel/bin/cuda.js +23 -26
- package/kernel/shell.js +33 -29
- package/package.json +1 -1
package/kernel/bin/cuda.js
CHANGED
|
@@ -14,22 +14,30 @@ class Cuda {
|
|
|
14
14
|
)
|
|
15
15
|
} catch (e) {}
|
|
16
16
|
}
|
|
17
|
-
async
|
|
17
|
+
async stashCompilerVarsScripts() {
|
|
18
18
|
if (this.kernel.platform !== "win32") {
|
|
19
19
|
return
|
|
20
20
|
}
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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.
|
|
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.
|
|
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,41 @@ class Shell {
|
|
|
949
949
|
if (params.build) {
|
|
950
950
|
if (this.platform === "win32") {
|
|
951
951
|
try {
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
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
|
-
|
|
972
|
+
console.log(`Unsupported arch: os.arch()=${architecture}, process.arch=${armArchitecture}`)
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
const compiler_cmd = [
|
|
976
|
+
`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")`,
|
|
977
|
+
`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")`,
|
|
978
|
+
`else if exist "%CONDA_PREFIX%\\etc\\conda\\activate.d\\vs2019_compiler_vars.bat" (call "%CONDA_PREFIX%\\etc\\conda\\activate.d\\vs2019_compiler_vars.bat")`,
|
|
979
|
+
`else if exist "%CONDA_PREFIX%\\etc\\conda\\activate.d\\vs2022_compiler_vars.bat" (call "%CONDA_PREFIX%\\etc\\conda\\activate.d\\vs2022_compiler_vars.bat")`,
|
|
980
|
+
]
|
|
981
|
+
if (vcvars_path && arg) {
|
|
982
|
+
compiler_cmd.push(`else if exist "${vcvars_path}" (CALL "${vcvars_path}" ${arg})`)
|
|
982
983
|
}
|
|
984
|
+
conda_activation.push(compiler_cmd.join(" "))
|
|
985
|
+
conda_activation.push("set TORCH_CUDA_ARCH_LIST=")
|
|
986
|
+
conda_activation.push("set CUDAARCHS=")
|
|
983
987
|
} catch (e) {
|
|
984
988
|
console.log('vc vars setup', e)
|
|
985
989
|
}
|