TypeError while installing PyTorch 1.0 from source on Windows 10

I’ve tried to build and install PyTorch 1.0 on Windows 10 with the following parameters:

  • Graphics Card: GeForce GTX 770
  • NVidia CUDA 10.0 + cuDNN
  • PyTorch 1.0
  • Anaconda Python 3.7
  • Visual Studio 2017

I’ve done the following steps from https://github.com/pytorch/pytorch#from-source:

conda install numpy pyyaml mkl mkl-include setuptools cmake cffi typing
git clone --recursive https://github.com/pytorch/pytorch
cd pytorch

set "VS150COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build"
set CMAKE_GENERATOR=Visual Studio 15 2017 Win64
set DISTUTILS_USE_SDK=1
set MSSdk=1

call "%VS150COMNTOOLS%\vcvarsall.bat" x64 -vcvars_ver=14.15
python setup.py install

But upon running setup.py I receive this error:

Building wheel torch-1.0.0a0+db5d313
running install
setup.py::run()
running build_deps
setup.py::build_deps::run()
Traceback (most recent call last):
  File "setup.py", line 1018, in <module>
    rel_site_packages + '/caffe2/**/*.py'
  File "C:\Programming\Anaconda3\lib\site-packages\setuptools\__init__.py", line 143, in setup
    return distutils.core.setup(**attrs)
  File "C:\Programming\Anaconda3\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "C:\Programming\Anaconda3\lib\distutils\dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "C:\Programming\Anaconda3\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "setup.py", line 685, in run
    self.run_command('build_deps')
  File "C:\Programming\Anaconda3\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "C:\Programming\Anaconda3\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "setup.py", line 443, in run
    build_libs(libs)
  File "setup.py", line 402, in build_libs
    if subprocess.call(build_libs_cmd + libs, env=my_env, **kwargs) != 0:
  File "C:\Programming\Anaconda3\lib\subprocess.py", line 317, in call
    with Popen(*popenargs, **kwargs) as p:
  File "C:\Programming\Anaconda3\lib\subprocess.py", line 769, in __init__
    restore_signals, start_new_session)
  File "C:\Programming\Anaconda3\lib\subprocess.py", line 1172, in _execute_child
    startupinfo)
TypeError: environment can only contain strings

Any ideas what might be the reason for this?

Oh, I just found out why it didn’t work: Building pytorch with Visual Studio + CUDA apparently requires the Cuda Visual Studio Integration to be installed. So I re-ran the CUDA installer and checked the appropriate box and now the build is running. Hope that this might help other too.

Glad you found that out. Apparently we should throw an exception here.

Well, now I have another problem:

"C:\Users\Alex\Repositories\pytorch\build\INSTALL.vcxproj" (default target) (1) ->
"C:\Users\Alex\Repositories\pytorch\build\ALL_BUILD.vcxproj" (default target) (3) ->
"C:\Users\Alex\Repositories\pytorch\build\caffe2\AlgorithmsTest.vcxproj" (default target) (4) ->
"C:\Users\Alex\Repositories\pytorch\build\caffe2\caffe2_gpu.vcxproj" (default target) (21) ->
(CustomBuild target) ->
  Error : Internal Compiler error (codegen): "there was an error in verifying the lgenfe output!" [C:\Users\Alex\Repositories\pytorch\build\caffe2\caffe2_gpu.vcxproj]

    24529 Warning(s)
    1 Error(s)

Time Elapsed 01:08:11.21

C:\Users\Alex\Repositories\pytorch\build>IF ERRORLEVEL 1 exit 1
Failed to run 'tools\build_pytorch_libs.bat --use-cuda --use-nnpack --use-mkldnn --use-qnnpack caffe2'