Error in Build Pytorch1.8 from source offline windows 10

Hello everyone, I try to build Pytorch 1.8 from source offline with VS 2019 (cuda11.1,cudnn8.2).

My Work Steps :

(1) I download the source code from GitHub - pytorch/pytorch at v1.8.1 (with all third party from their github).

(2) Install VS 2019 community (16.4.5 version).

(3) Install cuda11.1 , and test the command “nvcc -V” well.

(4) Install cudnn8.2 .

(5) Install anaconda and create enviroment (python==3.6) .

(6) Activate this enviromente and Follow the common reqiurements of GitHub - pytorch/pytorch at v1.8.1 , “conda install numpy ninja pyyaml mkl mkl-include setuptools cmake cffi typing_extensions future six requests dataclasses”, the result of install is okay.

(7) Refer to build_pytorch.bat .Then I download MKL ,MAGMA,SSCAHE,and Randomtemp.exe.

(8) I make a batch file script ,like the above [build_pytorch.bat].The key point lines are :
" echo @“E:\build_torch\needed\bin\randomtemp.exe” “E:\build_torch\needed\bin\sccache.exe” “%CUDA_PATH%\bin\nvcc.exe” %%* > “%TMP_DIR%\bin\nvcc.bat”

cat %TMP_DIR%\bin\nvcc.bat

set CUDA_NVCC_EXECUTABLE=%TMP_DIR%\bin\nvcc.bat "

(9) when I acitvate env and set my batch file script to build, MKL MAGMA SSCAHE could find and work,but the above 3 lines will cause that error “cuda could not found” .
Because in FindCUDA.camke line 786 “execute_process(COMMAN ${CUDA_NVCC_EXECUTABLE}) “–VERSION” ” , nvcc.bat do not work.
And CMAKE will modify USE_CUDA = 0.
This building result without cuda is not my target.

(10) Next time , I modify the above 3 lines . I just “set CUDA_NVCC_EXECUTABLE=%CUDA_PATH%\bin\nvcc.exe”.

(11) This time I set env vars and “python install --cmake”.
Cuda could find and work.
But Erros happen in about [4143/5177] :
BinaryLogicalOpsKernels.cuninja: build stopped: subcommand failed.
Traceback (most recent call last):
File “”, line 818, in
File “”, line 320, in build_deps
File “E:\build_torch\B14\pytorch\tools\”, line 58, in build_caffe2
File “E:\build_torch\B14\pytorch\tools\setup_helpers\”, line 345, in build, my_env)
File “E:\build_torch\B14\pytorch\tools\setup_helpers\”, line 140, in run
check_call(command, cwd=self.build_dir, env=env)
File “E:\Anaconda3\envs\mtorch\lib\”, line 311, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command ‘[‘cmake’, ‘–build’, ‘.’, ‘–target’, ‘install’, ‘–config’, ‘Release’, ‘–’, ‘-j’, ‘8’]’ returned non-zero exit status 1.”

So I wanna know what’s wrong with my work ,please help me, many thanks!

This is latest collapse error in building process[4149/5117]:

and breakdown:

(1)Probably, I guess this error about nvcc.

(2)Because, before this time I set wrong env var :
“set CUDAHOSTCXX=D:\Program Files\Microsoft Visual

(3)And then ,build breakdown in [4059/5117], error : “nvcc fatal : nvcc fatal : Failed to preprocess host compiler properties”

(4)In fact,the right way of CUDAHOSTCXX is “D:\Program Files(x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\bin\HostX64\x64\cl.exe”

(5)Next , I modified it and restarted to build.

break down in the above pics [4149/5117].

Could you give me some solutions ? Many thanks!

@peterjc123 hi ,sorry to bother you,I have a question .

(1) when I set like you did in build_pytorch.bat:(about .exe file I download in “E:\build_torch\needed"; )

 echo @“E:\build_torch\needed\bin\randomtemp.exe” 

 E:\build_torch\needed\bin\sccache.exe” “%CUDA_PATH%\bin\nvcc.exe” %%* > “%TMP_DIR%\bin\nvcc.bat”

 cat %TMP_DIR%\bin\nvcc.bat

 set CUDA_NVCC_EXECUTABLE=%TMP_DIR%\bin\nvcc.bat"

(2) Beginning, CUDA error in build process, FindCUDA.camke line 790 “execute_process(COMMAN ${CUDA_NVCC_EXECUTABLE}) “–VERSION” ” ,
It returned that “Failed to execute ‘E:/build_torch/tmp/bin/nvcc.bat --version’”, as:

CMake Warning at cmake/Modules_CUDA_fix/upstream/FindCUDA.cmake:790 (message):

** Failed to execute ‘E:/build_torch/tmp/bin/nvcc.bat --version’**
Call Stack (most recent call first):

** cmake/Modules_CUDA_fix/FindCUDA.cmake:11 (include)**

cmake/public/cuda.cmake:29 (find_package)

cmake/Dependencies.cmake:1148 (include)

CMakeLists.txt:564 (include)

(3) Thus, cuda cannot be found.

what's wrong with this set env var? Could you please help me