Skip to content

How to install Pytorch3d in windows 10 with pytorch 1.5.1, torchvision 0.6.1, cudatoolkit 9.2 and Visual studio 2019 professional #735

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

Closed
pravinjaisawal opened this issue Jun 29, 2021 · 2 comments
Assignees
Labels
installation Installation questions or issues

Comments

@pravinjaisawal
Copy link

pravinjaisawal commented Jun 29, 2021

I am following the instruction mentioned at install.md.
Instruction used:

conda create -n pytorch3d python=3.8
conda activate pytorch3d
conda install -c pytorch pytorch=1.5.1 torchvision cudatoolkit=9.2
conda install -c fvcore -c iopath -c conda-forge fvcore iopath

But
conda install -c bottler nvidiacub doesnot work with following error:

PackagesNotFoundError: The following packages are not available from current channels:

  - nvidiacub

Current channels:

  - https://conda.anaconda.org/bottler/win-64
  - https://conda.anaconda.org/bottler/noarch
  - https://repo.anaconda.com/pkgs/main/win-64
  - https://repo.anaconda.com/pkgs/main/noarch
  - https://repo.anaconda.com/pkgs/r/win-64
  - https://repo.anaconda.com/pkgs/r/noarch
  - https://repo.anaconda.com/pkgs/msys2/win-64
  - https://repo.anaconda.com/pkgs/msys2/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

    https://anaconda.org

and use the search bar at the top of the page.

So, I downloaded CUB library version 1.10.0 from [https://github.com/NVIDIA/cub/releases ]. And defined environment variable CUB_HOME which points to cmakelist of downloaded CUB library.

This instruction works as expected:

conda install jupyter
pip install scikit-image matplotlib imageio plotly opencv-python
pip install black 'isort<5' flake8 flake8-bugbear flake8-comprehensions

Now for pytorch3d:
I downloaded pytorch3d with git clone https://github.com/facebookresearch/pytorch3d.git and try to install with
pip install -e . but it gives following error:

Obtaining file:///D:/abc/pytorch3d
Requirement already satisfied: fvcore in d:\abc\anaconda\envs\depth_est\lib\site-packages (from pytorch3d==0.4.0) (0.1.5.post20210624)
Requirement already satisfied: iopath in d:\abc\anaconda\envs\depth_est\lib\site-packages (from pytorch3d==0.4.0) (0.1.9)
Requirement already satisfied: numpy in d:\abc\anaconda\envs\depth_est\lib\site-packages (from fvcore->pytorch3d==0.4.0) (1.20.2)
Requirement already satisfied: yacs>=0.1.6 in d:\abc\anaconda\envs\depth_est\lib\site-packages (from fvcore->pytorch3d==0.4.0) (0.1.6)
Requirement already satisfied: pyyaml>=5.1 in d:\abc\anaconda\envs\depth_est\lib\site-packages (from fvcore->pytorch3d==0.4.0) (5.4.1)
Requirement already satisfied: tqdm in d:\abc\anaconda\envs\depth_est\lib\site-packages (from fvcore->pytorch3d==0.4.0) (4.61.1)
Requirement already satisfied: termcolor>=1.1 in d:\abc\anaconda\envs\depth_est\lib\site-packages (from fvcore->pytorch3d==0.4.0) (1.1.0)
Requirement already satisfied: Pillow in d:\abc\anaconda\envs\depth_est\lib\site-packages (from fvcore->pytorch3d==0.4.0) (8.2.0)
Requirement already satisfied: tabulate in d:\abc\anaconda\envs\depth_est\lib\site-packages (from fvcore->pytorch3d==0.4.0) (0.8.9)
Requirement already satisfied: portalocker in d:\abc\anaconda\envs\depth_est\lib\site-packages (from iopath->pytorch3d==0.4.0) (1.7.0)
Requirement already satisfied: pywin32!=226 in d:\abc\anaconda\envs\depth_est\lib\site-packages (from portalocker->iopath->pytorch3d==0.4.0) (300)
Installing collected packages: pytorch3d
  Running setup.py develop for pytorch3d
    ERROR: Command errored out with exit status 1:
     command: 'D:\abc\anaconda\envs\depth_est\python.exe' -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'D:\\abc\\pytorch3d\\setup.py'"'"'; __file__='"'"'D:\\abc\\pytorch3d\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps
         cwd: D:\abc\pytorch3d\
    Complete output (20 lines):
    running develop
    running egg_info
    creating pytorch3d.egg-info
    writing pytorch3d.egg-info\PKG-INFO
    writing dependency_links to pytorch3d.egg-info\dependency_links.txt
    writing requirements to pytorch3d.egg-info\requires.txt
    writing top-level names to pytorch3d.egg-info\top_level.txt
    writing manifest file 'pytorch3d.egg-info\SOURCES.txt'
    reading manifest file 'pytorch3d.egg-info\SOURCES.txt'
    writing manifest file 'pytorch3d.egg-info\SOURCES.txt'
    running build_ext
    building 'pytorch3d._C' extension
    D:\abc\anaconda\envs\depth_est\lib\site-packages\torch\utils\cpp_extension.py:238: UserWarning: Error checking compiler version for cl: [WinError 2] Das System kann die angegebene Datei nicht finden
      warnings.warn('Error checking compiler version for {}: {}'.format(compiler, error))
    error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
    Error in atexit._run_exitfuncs:
    Traceback (most recent call last):
      File "D:\abc\anaconda\envs\depth_est\lib\site-packages\colorama\ansitowin32.py", line 59, in closed
        return stream.closed
    ValueError: underlying buffer has been detached
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'D:\abc\anaconda\envs\depth_est\python.exe' -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'D:\\abc\\pytorch3d\\setup.py'"'"'; __file__='"'"'D:\\abc\\pytorch3d\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps Check the logs for full command output.

Following #172, I check if I have the following files:

D:\dev\pytorch3d\pytorch3d\csrc   - Yes
C:\ProgramData\Anaconda3\envs\vtk\lib\site-packages\torch\include - Yes
C:\ProgramData\Anaconda3\envs\vtk\lib\site-packages\torch\include\torch\csrc\api\include  -Yes
C:\ProgramData\Anaconda3\envs\vtk\lib\site-packages\torch\include\TH  -Yes
C:\ProgramData\Anaconda3\envs\vtk\lib\site-packages\torch\include\THC  -Yes
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\include  -No
C:\ProgramData\Anaconda3\envs\vtk\include  - Yes
C:\ProgramData\Anaconda3\envs\vtk\include - Yes
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.27.29110\ATLMFC\include -Yes
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.27.29110\include -Yes
C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um -No
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt -Yes
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared -Yes
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um -Yes
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt -Yes
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt -Yes

I also tried:
Change python\Lib\site-packages\torch\include\torch\csrc\jit\api\module.h
-all locations

-static constexpr *
+static const *

Change python/Lib/site-packages/torch/include/csrc/runtime/argument_spec.h

-static constexpr size_t DEPTH_LIMIT = 128;
+static const size_t DEPTH_LIMIT = 128;

Change python/Lib/site-packages/torch/include/pybind11/cast.h

-explicit operator type&() { return *(this->value); }
+explicit operator type& () { return *((type*)(this->value)); }

After patching, you can go to "Developer Command Prompt for VS 2019" to compile and install

cd pytorch3d
python3 setup.py install 

But I get following error:

D:\abc\anaconda\envs\depth_est\lib\site-packages\torch\utils\cpp_extension.py:238: UserWarning: Error checking compiler version for cl: [WinError 2] Das System kann die angegebene Datei nicht finden
  warnings.warn('Error checking compiler version for {}: {}'.format(compiler, error))
building 'pytorch3d._C' extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/

This error is quite surprising because I have VIsual Studion 2019 working properly.

@patricklabatut
Copy link
Contributor

you can go to "Developer Command Prompt for VS 2019" to compile and install
[...]
D:\abc\anaconda\envs\depth_est\lib\site-packages\torch\utils\cpp_extension.py:238: UserWarning: Error checking compiler version for cl: [WinError 2] Das System kann die angegebene Datei nicht finden
warnings.warn('Error checking compiler version for {}: {}'.format(compiler, error))

Could you double-check that after this step (opening a terminal set up for MSVC), cl.exe is indeed in the PATH and matches MSVC 2019?

@patricklabatut patricklabatut added the installation Installation questions or issues label Jun 29, 2021
@pravinjaisawal
Copy link
Author

I was indeed missing MSVC. I installed Desktop Development with C++ and tried again, pytorch3d got installed successfully.

@facebookresearch facebookresearch locked as resolved and limited conversation to collaborators Jul 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
installation Installation questions or issues
Projects
None yet
Development

No branches or pull requests

3 participants