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

Error in installing Pytorch3D on windows #1299

Closed
supriya-gdptl opened this issue Aug 17, 2022 · 15 comments
Closed

Error in installing Pytorch3D on windows #1299

supriya-gdptl opened this issue Aug 17, 2022 · 15 comments

Comments

@supriya-gdptl
Copy link

supriya-gdptl commented Aug 17, 2022

🐛 Bugs / Unexpected behaviors

I am trying to install Pytorch3D on Windows 10. and getting an error:

 ninja: build stopped: subcommand failed.
    Traceback (most recent call last):
      File "C:\Users\Anaconda3\envs\roca\lib\site-packages\torch\utils\cpp_extension.py", line 1667, in _run_ninja_build
        subprocess.run(
      File "C:\Users\Anaconda3\envs\roca\lib\subprocess.py", line 516, in run
        raise CalledProcessError(retcode, process.args,
    subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

More info on the conda environment I am using:

OS=Windows 10
Python=3.8
torch=1.8.0
cudatoolkit=11.1
fvcore=0.1.5.post20220512
iopath=0.1.9
ninja=1.10.2.3
numpy=1.22.4
pycocotools=2.0.4
pywin32=302

Instructions To Reproduce the Issue:

  1. I used following commands on "x64 Native Tools Command Prompt for VS 2019" to install Pytorch3D
git clone https://github.com/facebookresearch/pytorch3d.git
cd pytorch3d
python setup.py install
  1. It gives following error:
C:\Users\Anaconda3\envs\my_conda_env\lib\site-packages\torch\include\ATen/cuda/Exceptions.h(54): error C2373: 'cusparseGetErrorString': redefinition; different type modifiers
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\include\cusparse.h(304): note: see declaration of 'cusparseGetErrorString'
    ninja: build stopped: subcommand failed.
    Traceback (most recent call last):
      File "C:\Users\Anaconda3\envs\my_conda_env\lib\site-packages\torch\utils\cpp_extension.py", line 1667, in _run_ninja_build
        subprocess.run(
      File "C:\Users\Anaconda3\envs\my_conda_env\lib\subprocess.py", line 516, in run
        raise CalledProcessError(retcode, process.args,
    subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

    The above exception was the direct cause of the following exception:

    Traceback (most recent call last):
      File "<string>", line 2, in <module>
      File "<pip-setuptools-caller>", line 34, in <module>
      File "D:\code\pytorch3d\setup.py", line 144, in <module>
        setup(
      File "C:\Users\Anaconda3\envs\my_conda_env\lib\site-packages\setuptools\__init__.py", line 153, in setup
        return distutils.core.setup(**attrs)
      
      ...
      
      File "C:\Users\Anaconda3\envs\my_conda_env\lib\site-packages\torch\utils\cpp_extension.py", line 1354, in _write_ninja_file_and_compile_objects
        _run_ninja_build(
      File "C:\Users\Anaconda3\envs\my_conda_env\lib\site-packages\torch\utils\cpp_extension.py", line 1683, in _run_ninja_build
        raise RuntimeError(message) from e
    RuntimeError: Error compiling objects for extension
    [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.

Could you please tell if I am using correct steps? Is there any command that I missed in installing Pytorch3D which is causing this error?
Appreciate any help.
Thank you.

@supriya-gdptl
Copy link
Author

I tried suggestion given in #1230, #1227, #1226, but it did not resolve the error.

@cinamon123
Copy link

Can you use jupyter notebook?
I met the same prob when installing from source in jupyter.
But installing by conda-cloud is successful.
The most important thing is getting its dependent packets versions right.

@bottler
Copy link
Contributor

bottler commented Aug 19, 2022

Is there a log file with an error in it? If not, can you try without ninja? Make sure the environment variable PYTORCH3D_NO_NINJA is set to 1. You will get at least a more informative error

@supriya-gdptl
Copy link
Author

Thank you @bottler. Your suggestion was helpful to get more informative error (please see the attached error log file).
errorlog.txt

@supriya-gdptl
Copy link
Author

@cinamon123 Could you please elaborate on exact steps you followed to install? Thank you.

@bottler
Copy link
Contributor

bottler commented Aug 22, 2022

Interesting excerpts from that log file:

C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/include\vcruntime.h(197): error: invalid redeclaration of type name "size_t"

C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/include\vcruntime_new_debug.h(34): error: first parameter of allocation function must be of type "size_t"

C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/include\type_traits(407): error: class template "std::_Is_memfunptr" has already been defined

C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/include\type_traits(1739): error: class template "std::result_of" has already been defined

C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/include\type_traits(1849): error: class template "std::_Function_args" has already been defined

C:/Program Files (x86)/Windows Kits/10/include/10.0.19041.0/ucrt\malloc.h(55): error: more than one instance of overloaded function "_alloca" has "C" linkage

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\include\crt/common_functions.h(125): error: first parameter of allocation function must be of type "size_t"

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\include\sm_20_intrinsics.hpp(139): error: more than one instance of overloaded function "__nv_cvta_local_to_generic_impl" has "C" linkage

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\include\sm_20_intrinsics.hpp(194): error: asm operand type size(8) does not match type/size implied by constraint 'r'

I think this is a 32bit build (aka x86), but I don't know why. I think this nvcc expects only 64 bit builds (x64), and for 32 bit builds to fail, possibly in this way. Which command prompt are you running in?

@supriya-gdptl
Copy link
Author

I am using "x64 Native Tools Command Prompt for VS 2019".

@bottler
Copy link
Contributor

bottler commented Aug 22, 2022

That's good. It should do x64 builds. So I'm not sure what is going on.

@supriya-gdptl
Copy link
Author

I added the CUB_HOME to list of environment variables, restarted the machine and run the commands on x64 command prompt again. This time the installation progressed to some extent but ended with following three errors:

D:\research\code\pytorch3d\pytorch3d\csrc\pulsar\cuda\renderer.backward.gpu.cu -o build\temp.win-amd64-cpython-38\Release\research\code\pytorch3d\pytorch3d\csrc\pulsar\cuda\renderer.backward.gpu.obj -ID:\research\code\pytorch3d\pytorch3d\csrc "-IC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\include\cub" -IC:\Users\Anaconda3\envs\roca\lib\site-packages\torch\include -IC:\Users\Anaconda3\envs\roca\lib\site-packages\torch\include\torch\csrc\api\include -IC:\Users\Anaconda3\envs\roca\lib\site-packages\torch\include\TH -IC:\Users\Anaconda3\envs\roca\lib\site-packages\torch\include\THC "-IC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\include" -IC:\Users\Anaconda3\envs\roca\include -IC:\Users\Anaconda3\envs\roca\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt" -Xcudafe --diag_suppress=dll_interface_conflict_dllexport_assumed -Xcudafe --diag_suppress=dll_interface_conflict_none_assumed -Xcudafe --diag_suppress=field_without_dll_interface -Xcudafe --diag_suppress=base_class_has_different_dll_interface -Xcompiler /EHsc -Xcompiler /wd4190 -Xcompiler /wd4018 -Xcompiler /wd4275 -Xcompiler /wd4267 -Xcompiler /wd4244 -Xcompiler /wd4251 -Xcompiler /wd4819 -Xcompiler /MD -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr -DCUDA_HAS_FP16=1 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_86,code=compute_86 -gencode=arch=compute_86,code=sm_86 --use-local-env
D:\research\code\pytorch3d\pytorch3d\csrc\pulsar\include\../global.h(33): warning #20236-D: pragma "diag_suppress" is deprecated, use "nv_diag_suppress" instead

D:\research\code\pytorch3d\pytorch3d\csrc\pulsar\include\../global.h(34): warning #20236-D: pragma "diag_suppress" is deprecated, use "nv_diag_suppress" instead

D:\research\code\pytorch3d\pytorch3d\csrc\pulsar\include\../global.h(35): warning #20236-D: pragma "diag_suppress" is deprecated, use "nv_diag_suppress" instead

D:\research\code\pytorch3d\pytorch3d\csrc\pulsar\include\../global.h(36): warning #20236-D: pragma "diag_suppress" is deprecated, use "nv_diag_suppress" instead

D:\research\code\pytorch3d\pytorch3d\csrc\pulsar\include\../global.h(37): warning #20236-D: pragma "diag_suppress" is deprecated, use "nv_diag_suppress" instead

D:\research\code\pytorch3d\pytorch3d\csrc\pulsar\include\../global.h(33): warning #20236-D: pragma "diag_suppress" is deprecated, use "nv_diag_suppress" instead

D:\research\code\pytorch3d\pytorch3d\csrc\pulsar\include\../global.h(34): warning #20236-D: pragma "diag_suppress" is deprecated, use "nv_diag_suppress" instead

D:\research\code\pytorch3d\pytorch3d\csrc\pulsar\include\../global.h(35): warning #20236-D: pragma "diag_suppress" is deprecated, use "nv_diag_suppress" instead

D:\research\code\pytorch3d\pytorch3d\csrc\pulsar\include\../global.h(36): warning #20236-D: pragma "diag_suppress" is deprecated, use "nv_diag_suppress" instead

D:\research\code\pytorch3d\pytorch3d\csrc\pulsar\include\../global.h(37): warning #20236-D: pragma "diag_suppress" is deprecated, use "nv_diag_suppress" instead

C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.7/include\cub/device/dispatch/dispatch_segmented_sort.cuh(338): error: invalid combination of type specifiers

C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.7/include\cub/device/dispatch/dispatch_segmented_sort.cuh(338): error: expected an identifier

C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.7/include\cub/device/dispatch/dispatch_segmented_sort.cuh(379): error: expected a member name

3 errors detected in the compilation of "D:/research/code/pytorch3d/pytorch3d/csrc/pulsar/cuda/renderer.backward.gpu.cu".
renderer.backward.gpu.cu

@bottler
Copy link
Contributor

bottler commented Aug 22, 2022

Can you get CUB 1.16.0 or newer and set CUB_HOME to that?

@cinamon123
Copy link

@cinamon123 Could you please elaborate on exact steps you followed to install? Thank you.

It is my pleasure to help you ! Well, I post a summery on CSDN (a Chinese website). If you want some more details, you can visit through this link:
https://blog.csdn.net/m0_65517918/article/details/126318356
I just put some vital steps below(that's enough I think):
using: jupyter+conda cloud+pip

conda create -n pytorch3d python=3.8 (or 3.9) 
conda activate pytorch3d
conda install -c pytorch=1.9.1 torchvision cudatoolkit=10.2
conda install -c fvcore -c iopath -c conda-forge fvcore iopath

conda install -c bottler nvidiacub

conda install jupyter
pip install scikit-image matplotlib imageio plotly opencv-python

pip install black usort flake8 flake8-bugbear flake8-comprehensions

conda install pytorch3d -c pytorch3d

tips: All these steps come from MD by Pytoech3D-team.
Do not skip any step.
The version of dependent-package is important. Or conda-cloud will not find a proper version in the last step.

Good Luck my friend~

@supriya-gdptl
Copy link
Author

Thank you for the suggestion @bottler. It worked. I installed Pytorch3D on Windows.

The steps I followed are as follows:

  1. Download CUB 1.17.1 source code (zip) from here: https://github.com/NVIDIA/cub/releases/tag/1.17.1
  2. Extract and copy "cub-1.17.1" folder to "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\include"
  3. Add new environment variable CUB_HOME=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\include\cub-1.17.1
    NOTE: at this point if you try to install pytorch3d with command "python setup.py install", you may get an error C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\include\thrust\system\cuda\config.h(78): fatal error C1189: #error: The version of CUB in your include path is not compatible with this release of Thrust. CUB is now included in the CUDA Toolkit, so you no longer need to use your own checkout of CUB. Define THRUST_IGNORE_CUB_VERSION_CHECK to ignore this. ball_query.cu
    Follow next step to resolve it.
  4. Edit config.h located at "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\include\thrust\system\cuda\config.h". Search for line #ifndef THRUST_IGNORE_CUB_VERSION_CHECK and add line #define THRUST_IGNORE_CUB_VERSION_CHECK below it.
    (credit: How to Define THRUST_IGNORE_CUB_VERSION_CHECK? Installaton on windows #1123, compile error with cuda-11.4 "Define THRUST_IGNORE_CUB_VERSION_CHECK to ignore this." spirit-code/spirit#602)
  5. In Windows menu, search for "x64 Native Tools Command Prompt for VS 2019" and open it.
  6. cd "folder_where_you_want_to_save_code" and git clone https://github.com/facebookresearch/pytorch3d.git
  7. cd pytorch3d
  8. conda activate "your_conda_env"
  9. set DISTUTILS_USE_SDK=1
  10. set PYTORCH3D_NO_NINJA=1
  11. python setup.py install

These steps worked on my Windows machine. Hope these work for others too
Thank you.

@Abhi011999
Copy link

Abhi011999 commented Sep 15, 2022

One correction -

  1. Edit config.h located at "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\include\thrust\system\cuda\config.h". Search for line #ifndef THRUST_IGNORE_CUB_VERSION_CHECK and add line #define THRUST_IGNORE_CUB_VERSION_CHECK below it.

We have to add the #define THRUST_IGNORE_CUB_VERSION_CHECK before the #ifndef THRUST_IGNORE_CUB_VERSION_CHECK line.

@JJab0n
Copy link

JJab0n commented Sep 30, 2022

Hello @supriya-gdptl ,

Which VS version are you using? I followed all the steps but I got the following error:

12 errors detected in the compilation of "C:/pytorch3d/pytorch3d/csrc/iou_box3d/iou_box3d.cu". error: command 'C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.3\\bin\\nvcc.exe' failed with exit code 1

I think it could be a version error as mentioned in #1024

@choos11
Copy link

choos11 commented Jul 16, 2024

谢谢你的建议。成功了。我在 Windows 上安装了 Pytorch3D。

我遵循的步骤如下:

  1. 从这里下载 CUB 1.17.1 源代码 (zip): https://github.com/NVIDIA/cub/releases/tag/1.17.1
  2. 解压并复制“cub-1.17.1”文件夹到“C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\include”
  3. 添加新的环境变量 CUB_HOME=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\include\cub-1.17.1 注意:此时,如果您尝试使用命令“python setup.py install”安装 pytorch3d,可能会收到错误 按照下一步操作来解决它。C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\include\thrust\system\cuda\config.h(78): fatal error C1189: #error: The version of CUB in your include path is not compatible with this release of Thrust. CUB is now included in the CUDA Toolkit, so you no longer need to use your own checkout of CUB. Define THRUST_IGNORE_CUB_VERSION_CHECK to ignore this. ball_query.cu
  4. 编辑位于“C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\include\thrust\system\cuda\config.h”的 config.h。搜索行并在其下方添加行。 (信用:#ifndef THRUST_IGNORE_CUB_VERSION_CHECK``#define THRUST_IGNORE_CUB_VERSION_CHECK如何定义THRUST_IGNORE_CUB_VERSION_CHECK?在 Windows 上安装 #1123,cuda-11.4 的编译错误“定义THRUST_IGNORE_CUB_VERSION_CHECK忽略此内容”。 精神代码/精神#602)
  5. 在 Windows 菜单中,搜索“适用于 VS 2019 的 x64 本机工具命令提示符”并将其打开。
  6. CD “folder_where_you_want_to_save_code” 和git clone https://github.com/facebookresearch/pytorch3d.git
  7. cd pytorch3d
  8. conda activate "your_conda_env"
  9. set DISTUTILS_USE_SDK=1
  10. set PYTORCH3D_NO_NINJA=1
  11. python setup.py install

这些步骤适用于我的 Windows 机器。希望这些也对其他人有用谢谢。

thanks very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants