Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cuda][win] add win cuda version check and cuda setting FAQ #140

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions docs/FAQ.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# FastDeploy FAQ 文档

## 1. 在Windows 10 配置 CUDA v11.2 环境变量
FastDeploy Windows 10 x64 的 GPU 版本需要依赖 CUDA 11.2,在安装完 CUDA v11.2 之后,需要设置`CUDA_DIRECTORY`、`CUDA_HOME`、`CUDA_PATH`和`CUDA_ROOT`中**任意一个**环境变量,这样FastDeploy才能链接到相关的库。有两种方式设置环境变量,通过终端命令行设置以及在系统环境变量中设置。
- 方式一: 终端命令行设置。该方式只在当前终端有效。Windows菜单打开`x64 Native Tools Command Prompt for VS 2019`命令工具,假设你需要在该终端运行类似`python infer_ppyoloe.py`的命令。
```bat
% 选择以下任意一个环境变量设置即可 %
set CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2
set CUDA_HOME=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2
set CUDA_ROOT=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2
set CUDA_DIRECTORY=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2
```
- 方式二: 系统环境变量设置。该方式会修改系统环境变量。设置步骤为:
- (1) 打开 "设置->系统->关于"
- (2) 找到 "高级系统设置",点击打开
- (3) 点击右下角的 "环境变量设置"
- (4) 注意,在 "系统变量" 一栏右下角点击 "新建",如果已有相关的环境变量,则只需确认路径是否正确
- (5) 设置`CUDA_DIRECTORY`、`CUDA_HOME`、`CUDA_PATH`和`CUDA_ROOT`中**任意一个**环境变量
- (6) 根据以下提示来设置环境变量,并点击确认
```text
变量名(N): CUDA_DIRECTORY、CUDA_HOME、CUDA_PATH和CUDA_ROOT中任意一个
变量值(V): 类似 C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2
```
17 changes: 15 additions & 2 deletions fastdeploy/c_lib_wrap.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ def add_cuda_shared_lib_dir_windows():
# paths. User should set it manually if the
# cuda toolkit is not locate in the default
# path we assume.
base_url = "https://github.com/PaddlePaddle/FastDeploy/blob/"
default_cuda_dir = get_default_cuda_directory()
default_cuda_version = os.path.basename(default_cuda_dir) # v11.2
cuda_shared_lib_dir = os.path.join(default_cuda_dir, "bin")
# TODO: add FAQ docs reference.
if not os.path.exists(cuda_shared_lib_dir):
# try to get cuda directory from user's local env
custom_cuda_dir = "NOTFOUNDED"
Expand All @@ -72,8 +73,20 @@ def add_cuda_shared_lib_dir_windows():
logging.warnings.warn(f"\n--- FastDeploy was built with gpu, \
\n--- but the default cuda directory does not exists. \
\n--- Please setup one of {custom_cuda_envs} manually, \
\n--- this path should look like: {default_cuda_dir}")
\n--- this path should look like: {default_cuda_dir}. \
\n--- Check FAQ: {base_url + 'develop/docs/FAQ.md'}")
return
# check cuda version
custom_cuda_version = os.path.basename(custom_cuda_dir) # v11.2
if default_cuda_version != custom_cuda_version:
logging.warnings.warn(
f"\n--- FastDeploy was built with CUDA version {default_cuda_version}, \
\n--- but found custom CUDA version {custom_cuda_version} at {custom_cuda_dir} \
\n--- Please setup one of {custom_cuda_envs} manually, \
\n--- this path should look like: {default_cuda_dir}. \
\n--- Check FAQ: {base_url + 'develop/docs/FAQ.md'}")
return
# path to cuda dlls
cuda_shared_lib_dir = os.path.join(custom_cuda_dir, "bin")
add_dll_search_dir(cuda_shared_lib_dir)
print(f"[FastDeploy][CUDA]: Found valid cuda directroy and added it: -> {cuda_shared_lib_dir}")
Expand Down