Last active
November 12, 2018 16:29
-
-
Save peterjc123/a4ac6ce4b0ed4b1b497334baaeb595e3 to your computer and use it in GitHub Desktop.
Setup script for Windows PyTorch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Prerequisites | |
# 1. MSVC 2017 C++ Build Tools | |
# 2. CMAKE 3.0 or up | |
# 3. 64 bits of Windows | |
# 4. Anaconda / MiniConda 64 bits | |
# Prerequisites for CUDA | |
# 1. CUDA 8.0 or up | |
# 2. NVTX( in CUDA as Visual Studio Integration. if fail to install, you can extract | |
# the CUDA installer exe and found the NVTX installer under the CUDAVisualStudioIntegration) | |
# 3. MSVC 2015 with Update 2 or up for CUDA 8 | |
# Optional | |
# 1. cuDNN 6.0 or up | |
# 2. Blas (MKL, OpenBlas) | |
git clone --recursive https://github.com/pytorch/pytorch | |
cd pytorch | |
xcopy /Y aten\src\ATen\common_with_cwrap.py tools\shared\cwrap_common.py | |
# Open X86_64 Developer Command Prompt for MSVC 2017 and type in the following commands: | |
# If you don't want to enable CUDA | |
set NO_CUDA=1 | |
# If multiple versions of CUDA are installed,it will build for the last one installed. To override | |
set CUDA_PATH=%CUDA_PATH_V8_0% | |
set PATH=%CUDA_PATH_V8_0%\bin;%PATH% | |
# or | |
set CUDA_PATH=%CUDA_PATH_V9_0% | |
set PATH=%CUDA_PATH_V9_0%\bin;%PATH% | |
# For CUDA 8 builds | |
set CMAKE_GENERATOR=Visual Studio 14 2015 Win64 | |
# For CUDA 9 / CPU builds | |
set CMAKE_GENERATOR=Visual Studio 15 2017 Win64 | |
# If you want to speed up CUDA builds, use Ninja | |
pip install ninja | |
set CMAKE_GENERATOR=Ninja | |
# If you use Ninja with CUDA 8 | |
set PREBUILD_COMMAND=%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat | |
set PREBUILD_COMMAND_ARGS=x86_amd64 | |
# If you want to save time for rebuilding it next time, use clcache | |
pip install git+https://github.com/frerich/clcache.git | |
set USE_CLCACHE=1 | |
set CC=clcache | |
set CXX=clcache | |
# If you want to add BLAS(OpenBLAS, MKL) | |
set LIB=[PATH_TO_BLAS_LIBS];%LIB% | |
# If your main python version is < 3.5 | |
set PYTHON_VERSION=3.5 # 3.6 or up is also fine | |
conda create -q -n test python=PYTHON_VERSION numpy mkl cffi pyyaml | |
activate test | |
# If you have both VS2015 and VS2017 | |
set DISTUTILS_USE_SDK=1 | |
# Now you can start install PyTorch here | |
python setup.py install |
@peterjc123
Hi Peter,
I get error code here...
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.5/Modules/CMakeDetermineCCompiler.cmake:57 (message):
Could not find compiler set in environment variable CC:
clcache.
Call Stack (most recent call first):
CMakeLists.txt:9 (project)
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
ninja: error: loading 'build.ninja':
could you help me fix that?
thanks
Guys, don't ask here. Since there's no notification on this. Please ask here instead.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@peterjc123
Hi Peter,
I have the following error while building:
"C:\Users\Utilisateur\OneDrive\Documents\git\pytorch\torch\lib\build\ATen\INSTALL.vcxproj" (default target) (1) ->
"C:\Users\Utilisateur\OneDrive\Documents\git\pytorch\torch\lib\build\ATen\ALL_BUILD.vcxproj" (default target) (3) ->
"C:\Users\Utilisateur\OneDrive\Documents\git\pytorch\torch\lib\build\ATen\src\ATen\ATen.vcxproj" (default target) (4) -
(Link target) ->
THAtomic.obj : error LNK2019: unresolved external symbol __InterlockedExchange64 referenced in function _THAtomicSetL
ong [C:\Users\Utilisateur\OneDrive\Documents\git\pytorch\torch\lib\build\ATen\src\ATen\ATen.vcxproj]
THAtomic.obj : error LNK2019: unresolved external symbol __InterlockedExchangeAdd64 referenced in function _THAtomicA
ddLong [C:\Users\Utilisateur\OneDrive\Documents\git\pytorch\torch\lib\build\ATen\src\ATen\ATen.vcxproj]
C:\Users\Utilisateur\OneDrive\Documents\git\pytorch\torch\lib\build\ATen\src\ATen\Release\ATen.dll : fatal error LNK1
120: 2 unresolved externals [C:\Users\Utilisateur\OneDrive\Documents\git\pytorch\torch\lib\build\ATen\src\ATen\ATen.vcx
proj]