Skip to content

Commit a649cd9

Browse files
committed
update document
1 parent 8fa64c7 commit a649cd9

File tree

8 files changed

+63
-41
lines changed

8 files changed

+63
-41
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pip install -r requirements.txt
3434
```
3535
#### Notes
3636
- When running `npm run dev`, pay attention to the `server.proxy` configuration in `vite.config.ts`, it should match the address of the `FastAPI` service you started.
37-
- If you encounter errors like *Couldn't import the plugin "https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-without-source@latest/dist/index.js"*, it may be that your network cannot access `cdn.jsdelivr.net`. Please find a proxy or acceleration node and replace it in `project.inlang/settings.json`.
37+
- If you encounter errors like *Couldn't import the plugin "https://xxxxxxxxx.xxx/xxxxxxxxxxxx"*, it may be that your network cannot access `cdn.jsdelivr.net`. Please find a proxy or acceleration node and replace it in `project.inlang/settings.json`.
3838

3939
### Unit Testing
4040
#### Writing Unit Tests

README.zh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pip install -r requirements.txt
3232
```
3333
#### 注意事项
3434
- 运行 `npm run dev` 时需要注意 `vite.config.ts` 中的 `server.proxy` 配置, 应该确保与你启动的 `FastAPI` 服务地址一致。
35-
- 如果出现 *Couldn't import the plugin "https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-without-source@latest/dist/index.js"* 类似的错误,可能是你的网络无法访问 `cdn.jsdelivr.net`,请自行寻找代理或者加速节点并在 `project.inlang/settings.json` 中进行替换。
35+
- 如果出现 *Couldn't import the plugin "https://xxxxxxxxx.xxx/xxxxxxxxxxxx"* 类似的错误,可能是你的网络无法访问 `cdn.jsdelivr.net`,请自行寻找代理或者加速节点并在 `project.inlang/settings.json` 中进行替换。
3636

3737
### 单元测试
3838
#### 编写单元测试

darkit/core/web/project.inlang/settings.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
"zh"
77
],
88
"modules": [
9-
"https://fastly.jsdelivr.net/npm/@inlang/message-lint-rule-empty-pattern@latest/dist/index.js",
10-
"https://fastly.jsdelivr.net/npm/@inlang/message-lint-rule-missing-translation@latest/dist/index.js",
11-
"https://fastly.jsdelivr.net/npm/@inlang/message-lint-rule-without-source@latest/dist/index.js",
12-
"https://fastly.jsdelivr.net/npm/@inlang/plugin-message-format@latest/dist/index.js",
13-
"https://fastly.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@latest/dist/index.js"
9+
"https://jsd.onmicrosoft.cn/npm/@inlang/message-lint-rule-empty-pattern@latest/dist/index.js",
10+
"https://jsd.onmicrosoft.cn/npm/@inlang/message-lint-rule-missing-translation@latest/dist/index.js",
11+
"https://jsd.onmicrosoft.cn/npm/@inlang/message-lint-rule-without-source@latest/dist/index.js",
12+
"https://jsd.onmicrosoft.cn/npm/@inlang/plugin-message-format@latest/dist/index.js",
13+
"https://jsd.onmicrosoft.cn/npm/@inlang/plugin-m-function-matcher@latest/dist/index.js"
1414
],
1515
"plugin.inlang.messageFormat": {
1616
"pathPattern": "./messages/{languageTag}.json"

docs/2.User-guide/1.Installation-guide.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,15 @@ We recommend using Anaconda as the Python environment manager.
5656
```
5757
5858
## Possible Issues
59-
1. If you encounter the error `RuntimeError: Error building extension 'wkv'` and see `nvcc: not found` or similar messages in the error details.
59+
1. If you encounter the error `Your compiler (c++) is not compatible with the compiler Pytorch was built with for this platform`.
60+
61+
You need to install the corresponding compiler version used when PyTorch was compiled:
62+
```bash
63+
# Install g++, according to your environment
64+
conda install -c conda-forge gxx_linux-64
65+
```
66+
67+
2. If you encounter the error `RuntimeError: Error building extension 'wkv'` and see `nvcc: not found` or similar messages in the error details.
6068
6169
This error may be due to the incorrect nvcc path. If CUDA is not installed, install CUDA. If CUDA is installed, add the CUDA path to the environment variables.
6270
@@ -65,15 +73,17 @@ We recommend using Anaconda as the Python environment manager.
6573
## Do not add bin at the end of the path, as it will cause duplicate bin folders
6674
export CUDA_HOME=/usr/local/cuda-12.3
6775
```
68-
2. #error -- unsupported GNU version! gcc versions later than 13 are not supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.
76+
77+
3. #error -- unsupported GNU version! gcc versions later than 13 are not supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.
6978
7079
This error occurs because CUDA 11.4 does not support gcc versions higher than 13. You need to downgrade the gcc version. You can install gcc 13.3.0 using conda.
7180
```bash
7281
conda install -c conda-forge gcc_linux-64=13.3.0
7382
# If there is a version mismatch, try the following command
7483
# conda install -c conda-forge gxx_linux-64=13.3.0 --override-channels -c conda-forge
7584
```
76-
3. fatal error: cuda_runtime.h: No such file or directory
85+
86+
4. fatal error: cuda_runtime.h: No such file or directory
7787
7888
This error can be resolved as follows:
7989
```shell
@@ -83,21 +93,21 @@ We recommend using Anaconda as the Python environment manager.
8393
export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/usr/local/cuda-12.3/include
8494
```
8595
86-
4. If you encounter the error `UnicodeDecodeError: 'gbk' codec can't decode byte 0x84 in position 116: illegal multibyte sequence`,
96+
5. If you encounter the error `UnicodeDecodeError: 'gbk' codec can't decode byte 0x84 in position 116: illegal multibyte sequence`,
8797
This error may be due to the open function in the read_version method in setup.py not matching the file encoding. Modify the open function to specify the correct encoding, such as utf-8:
8898
```python
8999
def read_version():
90100
with open(os.path.join("darkit", "__init__.py"), encoding="utf-8") as f:
91101
```
92102

93-
5. If you encounter the error `subprocess.CalledProcessError: Command '['which', 'c++']' returned non-zero exit status 1.`,
103+
6. If you encounter the error `subprocess.CalledProcessError: Command '['which', 'c++']' returned non-zero exit status 1.`,
94104
This error may be due to the lack of a C++ compiler. The solution is as follows:
95105
```bash
96106
sudo apt update
97107
sudo apt install build-essential
98108
```
99109

100-
6. If you choose to compile Graphviz from source and get error while installing `pip` package `nnviz`, probably the path of Graphviz installation is not specified. Please append the path to Graphviz installation in `C_INCLUDE_PATH`, `LD_FLAGS` and `LD_LIBRARY_PATH`.
110+
7. If you choose to compile Graphviz from source and get error while installing `pip` package `nnviz`, probably the path of Graphviz installation is not specified. Please append the path to Graphviz installation in `C_INCLUDE_PATH`, `LD_FLAGS` and `LD_LIBRARY_PATH`.
101111
```bash
102112
export C_INCLUDE_PATH=<graphviz_install_path>/include:$C_INCLUDE_PATH
103113
export LD_LIBRARY_PATH=<graphviz_install_path>/lib:$LD_LIBRARY_PATH

docs/zh/2.User-guide/1.Installation-guide.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
# 安装 cupy 用于加速计算, pygraphviz 用于可视化编辑模型
2626
conda install -c conda-forge cupy pygraphviz
2727
28-
# 安装 ninja 和 gcc 12 用于编译
29-
# 基于 CPU 的环境不需要安装 ninja 和 gcc 12
30-
conda install -c conda-forge ninja gcc_linux-64=12
28+
# 安装 ninja 用于编译
29+
# 基于 CPU 的环境不需要安装 ninja
30+
conda install -c conda-forge ninja
3131
```
3232

3333
5. 将本包安装到 Python 环境中:
@@ -61,7 +61,14 @@
6161
```
6262

6363
## 可能遇到的问题
64-
1. 如果在执行的过程中遇到了 `RuntimeError: Error building extension 'wkv'` 的错误,并且在错误详细信息中看到了 `nvcc: not found` 或类似的消息。
64+
1. 如果在执行过程中遇到了 `Your compiler (c++) is not compatible with the compiler Pytorch was built with for this platform` 的错误。
65+
66+
需要根据 PyTorch 编译时使用的编译器版本安装相应的编译器:
67+
```bash
68+
# 安装 g++, 根据你的环境
69+
conda install -c conda-forge gxx_linux-64
70+
```
71+
2. 如果在执行的过程中遇到了 `RuntimeError: Error building extension 'wkv'` 的错误,并且在错误详细信息中看到了 `nvcc: not found` 或类似的消息。
6572

6673
那么这个错误的原因可能是因为没有找到正确的 nvcc 的路径。如果没有安装 CUDA,则需要安装 CUDA。如果安装了 CUDA 则需要将 CUDA 的路径添加到环境变量中。
6774

@@ -70,15 +77,15 @@
7077
## 不要在路径后面加 bin,否则会导致重复的 bin 文件夹
7178
export CUDA_HOME=/usr/local/cuda-12.3
7279
```
73-
2. #error -- unsupported GNU version! gcc versions later than 13 are not supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.
80+
3. #error -- unsupported GNU version! gcc versions later than 13 are not supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.
7481

7582
这个错误是因为 CUDA 11.4 不支持比 gcc 13 更高的版本,需要降级 gcc 版本。可以使用 conda 安装 gcc 13.3.0。
7683
```bash
7784
conda install -c conda-forge gcc_linux-64=13.3.0
7885
# 如果提示版本不匹配,可以尝试使用以下命令
7986
# conda install -c conda-forge gxx_linux-64=13.3.0 --override-channels -c conda-forge
8087
```
81-
3. fatal error: cuda_runtime.h: No such file or directory
88+
4. fatal error: cuda_runtime.h: No such file or directory
8289

8390
这个错误可以通过以下方式解决:
8491
```shell
@@ -88,19 +95,21 @@
8895
# 将找到的路径添加到 CPLUS_INCLUDE_PATH 环境变量中
8996
export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/usr/local/cuda-12.3/include
9097
```
91-
4. 如果在执行的过程中遇到了 `UnicodeDecodeError: 'gbk' codec can't decode byte 0x84 in position 116: illegal multibyte sequence` 的错误,
98+
5. 如果在执行的过程中遇到了 `UnicodeDecodeError: 'gbk' codec can't decode byte 0x84 in position 116: illegal multibyte sequence` 的错误
99+
92100
那么这个错误的原因可能是因为 setup.py 中 read_version 方法中的 open 函数与文件的编码不符,修改 open 函数以指定正确的编码,如 utf-8:
93101
```python
94102
def read_version():
95103
with open(os.path.join("DarwinKit", "__init__.py"), encoding="utf-8") as f:
96104
```
97-
5. 如果在执行的过程中遇到了 `subprocess.CalledProcessError: Command '['which', 'c++']' returned non-zero exit status 1.`的错误,
105+
6. 如果在执行的过程中遇到了 `subprocess.CalledProcessError: Command '['which', 'c++']' returned non-zero exit status 1.`的错误
106+
98107
那么这个错误的原因可能是因为没有安装C++编译器,解决方法如下:
99108
```bash
100109
sudo apt update
101110
sudo apt install build-essential
102111
```
103-
6. 如果选择从源代码编译了 Graphviz 并在安装 pip 依赖项 nnviz 时遇到了问题,可能是没有指定 Graphviz 安装的路径。请在`C_INCLUDE_PATH`,`LD_FLAGS`和`LD_LIBRARY_PATH`中添加指向 Graphviz 安装位置的路径。
112+
7. 如果选择从源代码编译了 Graphviz 并在安装 pip 依赖项 nnviz 时遇到了问题,可能是没有指定 Graphviz 安装的路径。请在`C_INCLUDE_PATH`,`LD_FLAGS`和`LD_LIBRARY_PATH`中添加指向 Graphviz 安装位置的路径。
104113
```bash
105114
export C_INCLUDE_PATH=<graphviz_install_path>/include:$C_INCLUDE_PATH
106115
export LD_LIBRARY_PATH=<graphviz_install_path>/lib:$LD_LIBRARY_PATH

environment.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
name: darkit
22
channels:
33
- nvidia
4+
- pytorch
45
- conda-forge
56
- defaults
67
dependencies:
8+
- cupy
9+
- ninja
10+
- pytorch
11+
- pygraphviz
12+
- torchvision
713
- python=3.9
8-
- cupy=13.3
9-
- ninja=1.12
10-
- cuda-toolkit=12.2
11-
- cuda-nvcc=12.2
12-
- cuda-compiler=12.2
13-
- pygraphviz=1.11
14+
- pytorch-cuda=12.1
15+
- cuda-nvcc=12.1
16+
- cuda-toolkit=12.1
17+
- cuda-compiler=12.1

init.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from darkit.core.lib.options import save_models_metadata
2+
3+
try:
4+
from darkit.lm.models import Metadata as lm_metadata
5+
6+
save_models_metadata("lm", lm_metadata)
7+
print("Updated models options for lm.")
8+
except Exception as e:
9+
print(f"Error loading lm.models: {e}")

setup.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""
55

66
import os
7+
import subprocess
78
from setuptools import setup, find_packages
89
from darkit.core.utils import PWA_PATH
910

@@ -18,23 +19,12 @@ def read_version():
1819
return "0.0.1"
1920

2021

21-
def update_models_options():
22-
from darkit.core.lib.options import save_models_metadata
23-
24-
try:
25-
from darkit.lm.models import Metadata as lm_metadata
26-
27-
save_models_metadata("lm", lm_metadata)
28-
print("Updated models options for lm.")
29-
except Exception as e:
30-
print(f"Error loading lm.models: {e}")
31-
32-
3322
if not PWA_PATH.exists():
3423
print(f"Warning: PWA build not found at {PWA_PATH}")
3524
exit(1)
3625

37-
update_models_options()
26+
# 执行 init.py 文件
27+
subprocess.run(["python", "init.py"], check=True)
3828

3929
with open("./requirements.txt", "r", encoding="utf-8") as fh:
4030
install_requires = fh.read()

0 commit comments

Comments
 (0)