无法使用 CUDA 11.0、Python 3.8、Torch 1.8 编译项目
Failing to compile project using CUDA 11.0, Python 3.8, Torch 1.8
我正在尝试编译 DiffDVR,一个可微分的渲染器。这首先需要 运行ning cmake,所以我必须安装一些依赖项。我想使用与 repo 中的依赖项相同的依赖项。我正在使用 Linux Mint 20.3,它基于 Ubuntu 20.04。
按照顺序,我安装了:
- CUDA 11.0(使用官方runfile)
- cuDNN v8.1.1(与 11.0 兼容的最高版本,根据 cuDNN archive)
- 使用 Torch 1.8.0 创建了一个 Python 3.8 环境(基于回购中的 environment.yml 文件)
- 编译需要的 libglm-dev、libglfw3-dev 和 libglew-dev。
进入构建目录并 运行ning cmake ..
时出现的错误是:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
TORCH_LIB_c10
linked by target "Renderer" in directory /home/andrei/PycharmProjects/DiffDVR/renderer
linked by target "Gui" in directory /home/andrei/PycharmProjects/DiffDVR/gui
TORCH_LIB_c10_cuda
linked by target "Renderer" in directory /home/andrei/PycharmProjects/DiffDVR/renderer
linked by target "Gui" in directory /home/andrei/PycharmProjects/DiffDVR/gui
TORCH_LIB_torch_cpu
linked by target "Renderer" in directory /home/andrei/PycharmProjects/DiffDVR/renderer
linked by target "Gui" in directory /home/andrei/PycharmProjects/DiffDVR/gui
TORCH_LIB_torch_cuda
linked by target "Renderer" in directory /home/andrei/PycharmProjects/DiffDVR/renderer
linked by target "Gui" in directory /home/andrei/PycharmProjects/DiffDVR/gui
TORCH_LIB_torch_python
linked by target "Renderer" in directory /home/andrei/PycharmProjects/DiffDVR/renderer
linked by target "Gui" in directory /home/andrei/PycharmProjects/DiffDVR/gui
在输出中向上滚动显示以下问题:
Torch: full library list: /usr/lib/libtorch.so;TORCH_LIB_c10-NOTFOUND;TORCH_LIB_c10_cuda-NOTFOUND;/usr/lib/libtorch.so;TORCH_LIB_torch_cpu-NOTFOUND;TORCH_LIB_torch_cuda-NOTFOUND;TORCH_LIB_torch_python-NOTFOUND
所以好像找不到这些库。我尝试 sudo apt-get install libtorch3-dev
但 apt 说它已经安装(我假设它发生在 conda 安装 pytorch 包时?),并且没有可用的库与 c10、c10_cuda 等后缀。我如何确保找到这些库,以便我可以编译项目?
我通过以下(hacky)解决方案取得了一些进展:
sudo ln -s /home/andrei/miniconda3/envs/py38torch18/lib/python3.8/site-packages/torch/lib/libc10.so libc10.so
sudo ln -s /home/andrei/miniconda3/envs/py38torch18/lib/python3.8/site-packages/torch/lib/libc10_cuda.so libc10_cuda.so
sudo ln -s /home/andrei/miniconda3/envs/py38torch18/lib/python3.8/site-packages/torch/lib/libtorch_cpu.so libtorch_cpu.so
sudo ln -s /home/andrei/miniconda3/envs/py38torch18/lib/python3.8/site-packages/torch/lib/libtorch_cuda.so libtorch_cuda.so
sudo ln -s /home/andrei/miniconda3/envs/py38torch18/lib/python3.8/site-packages/torch/lib/libtorch_python.so libtorch_python.so
修复了之前的错误。
很遗憾,我现在遇到以下错误:
CMake Error at renderer/CMakeLists.txt:92 (add_library):
CUDA_STANDARD is set to invalid value '17'
更多进展:
通过 apt 卸载并通过 snap 重新安装(因为 apt 版本太旧),成功管理 运行 cmake。不幸的是,make
现在失败了,错误是:
[ 46%] Building CXX object renderer/CMakeFiles/Renderer.dir/volume.cpp.o
In file included from /opt/project/renderer/volume.cpp:1:
/opt/project/renderer/volume.h:9:10: fatal error: torch/types.h: No such file or directory
9 | #include <torch/types.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [renderer/CMakeFiles/Renderer.dir/build.make:76: renderer/CMakeFiles/Renderer.dir/volume.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:244: renderer/CMakeFiles/Renderer.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
更新:手动指定所有路径。就我而言,这是:
cmake .. -DTORCH_PATH=/home/andrei/miniconda3/envs/py38torch18/lib/python3.8/site-packages/torch -DTorch_DIR=/home/andrei/miniconda3/envs/py38torch18/lib/python3.8/site-packages/torch/share/cmake/Torch -DPYTHON_LIBRARY=/home/andrei/miniconda3/envs/py38torch18/lib/libpython3.8.so -DPYTHON_EXECUTABLE=/home/andrei/miniconda3/envs/py38torch18/bin/python
我正在尝试编译 DiffDVR,一个可微分的渲染器。这首先需要 运行ning cmake,所以我必须安装一些依赖项。我想使用与 repo 中的依赖项相同的依赖项。我正在使用 Linux Mint 20.3,它基于 Ubuntu 20.04。 按照顺序,我安装了:
- CUDA 11.0(使用官方runfile)
- cuDNN v8.1.1(与 11.0 兼容的最高版本,根据 cuDNN archive)
- 使用 Torch 1.8.0 创建了一个 Python 3.8 环境(基于回购中的 environment.yml 文件)
- 编译需要的 libglm-dev、libglfw3-dev 和 libglew-dev。
进入构建目录并 运行ning cmake ..
时出现的错误是:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
TORCH_LIB_c10
linked by target "Renderer" in directory /home/andrei/PycharmProjects/DiffDVR/renderer
linked by target "Gui" in directory /home/andrei/PycharmProjects/DiffDVR/gui
TORCH_LIB_c10_cuda
linked by target "Renderer" in directory /home/andrei/PycharmProjects/DiffDVR/renderer
linked by target "Gui" in directory /home/andrei/PycharmProjects/DiffDVR/gui
TORCH_LIB_torch_cpu
linked by target "Renderer" in directory /home/andrei/PycharmProjects/DiffDVR/renderer
linked by target "Gui" in directory /home/andrei/PycharmProjects/DiffDVR/gui
TORCH_LIB_torch_cuda
linked by target "Renderer" in directory /home/andrei/PycharmProjects/DiffDVR/renderer
linked by target "Gui" in directory /home/andrei/PycharmProjects/DiffDVR/gui
TORCH_LIB_torch_python
linked by target "Renderer" in directory /home/andrei/PycharmProjects/DiffDVR/renderer
linked by target "Gui" in directory /home/andrei/PycharmProjects/DiffDVR/gui
在输出中向上滚动显示以下问题:
Torch: full library list: /usr/lib/libtorch.so;TORCH_LIB_c10-NOTFOUND;TORCH_LIB_c10_cuda-NOTFOUND;/usr/lib/libtorch.so;TORCH_LIB_torch_cpu-NOTFOUND;TORCH_LIB_torch_cuda-NOTFOUND;TORCH_LIB_torch_python-NOTFOUND
所以好像找不到这些库。我尝试 sudo apt-get install libtorch3-dev
但 apt 说它已经安装(我假设它发生在 conda 安装 pytorch 包时?),并且没有可用的库与 c10、c10_cuda 等后缀。我如何确保找到这些库,以便我可以编译项目?
我通过以下(hacky)解决方案取得了一些进展:
sudo ln -s /home/andrei/miniconda3/envs/py38torch18/lib/python3.8/site-packages/torch/lib/libc10.so libc10.so
sudo ln -s /home/andrei/miniconda3/envs/py38torch18/lib/python3.8/site-packages/torch/lib/libc10_cuda.so libc10_cuda.so
sudo ln -s /home/andrei/miniconda3/envs/py38torch18/lib/python3.8/site-packages/torch/lib/libtorch_cpu.so libtorch_cpu.so
sudo ln -s /home/andrei/miniconda3/envs/py38torch18/lib/python3.8/site-packages/torch/lib/libtorch_cuda.so libtorch_cuda.so
sudo ln -s /home/andrei/miniconda3/envs/py38torch18/lib/python3.8/site-packages/torch/lib/libtorch_python.so libtorch_python.so
修复了之前的错误。
很遗憾,我现在遇到以下错误:
CMake Error at renderer/CMakeLists.txt:92 (add_library):
CUDA_STANDARD is set to invalid value '17'
更多进展:
通过 apt 卸载并通过 snap 重新安装(因为 apt 版本太旧),成功管理 运行 cmake。不幸的是,make
现在失败了,错误是:
[ 46%] Building CXX object renderer/CMakeFiles/Renderer.dir/volume.cpp.o
In file included from /opt/project/renderer/volume.cpp:1:
/opt/project/renderer/volume.h:9:10: fatal error: torch/types.h: No such file or directory
9 | #include <torch/types.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [renderer/CMakeFiles/Renderer.dir/build.make:76: renderer/CMakeFiles/Renderer.dir/volume.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:244: renderer/CMakeFiles/Renderer.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
更新:手动指定所有路径。就我而言,这是:
cmake .. -DTORCH_PATH=/home/andrei/miniconda3/envs/py38torch18/lib/python3.8/site-packages/torch -DTorch_DIR=/home/andrei/miniconda3/envs/py38torch18/lib/python3.8/site-packages/torch/share/cmake/Torch -DPYTHON_LIBRARY=/home/andrei/miniconda3/envs/py38torch18/lib/libpython3.8.so -DPYTHON_EXECUTABLE=/home/andrei/miniconda3/envs/py38torch18/bin/python