pinokiod 5.1.20 → 5.1.21

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.
Files changed (2) hide show
  1. package/kernel/bin/cuda.js +34 -0
  2. package/package.json +1 -1
@@ -2,6 +2,36 @@ const semver = require('semver')
2
2
  const fs = require('fs')
3
3
  const path = require('path')
4
4
  class Cuda {
5
+ async restoreCudaActivationScript() {
6
+ if (this.kernel.platform !== "win32") {
7
+ return
8
+ }
9
+ const folder = this.kernel.bin.path("miniconda/etc/conda/activate.d")
10
+ try {
11
+ await fs.promises.rename(
12
+ path.resolve(folder, "~cuda-nvcc_activate.bat.disabled"),
13
+ path.resolve(folder, "~cuda-nvcc_activate.bat")
14
+ )
15
+ } catch (e) {}
16
+ }
17
+ async patchCudaActivationScript() {
18
+ if (this.kernel.platform !== "win32") {
19
+ return
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))
33
+ }
34
+ }
5
35
  async install(req, ondata) {
6
36
  if (this.kernel.gpu === "nvidia") {
7
37
  if (this.kernel.platform === "win32") {
@@ -17,6 +47,8 @@ class Cuda {
17
47
  "conda install -y nvidia/label/cuda-12.8.1::cuda"
18
48
  ]
19
49
  }, ondata)
50
+ await this.restoreCudaActivationScript()
51
+ await this.patchCudaActivationScript()
20
52
  const folder = this.kernel.bin.path("miniconda/etc/conda/activate.d")
21
53
  let deactivate_list = [
22
54
  "vs2019_compiler_vars.bat",
@@ -54,6 +86,8 @@ class Cuda {
54
86
  async installed() {
55
87
  if (this.kernel.gpu === "nvidia") {
56
88
  if (this.kernel.platform === 'win32') {
89
+ await this.restoreCudaActivationScript()
90
+ await this.patchCudaActivationScript()
57
91
  if (this.kernel.bin.installed.conda.has("cudnn") && this.kernel.bin.installed.conda.has("cuda") && this.kernel.bin.installed.conda.has("libzlib-wapi")) {
58
92
  let version = this.kernel.bin.installed.conda_versions.cuda
59
93
  if (version) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "5.1.20",
3
+ "version": "5.1.21",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {