win10 源码编译libtorch(二)

94 篇文章 12 订阅

这次编译的时libtorch1.6.0,因为前面libtorch1.5.1有内存泄漏问题。

编译原因 cuda10.0支持。

先决条件:

  1. 安装了Visual Studio 2017.
  2. 安装了cuda10.0.
  3. 安装了anaconda.

1、下载pytorch源码

git clone -b可以选择分支来克隆,这里我使用的是1.4.0的版本。如果在编译的时候出现问题,可以尝试更换pytorch版本后重新编译。

git clone -b v1.6.0 --recursive https://github.com/pytorch/pytorch
cd pytorch
git submodule sync
git submodule update --init --recursive

python的一些包安装

conda install numpy ninja pyyaml mkl mkl-include setuptools cmake cffi

 

2、设置环境变量

2.1 打开Anaconda Prompt

2.2、添加环境变量

下面的需要根据自己的需要设置。

比如我的vs 2017的c++ 工具集是 14.16等其他不同

下面是参考博客的设置

# 如果设置为一,则编译出来的就是debug版本的libtorch
set DEBUG=1
# 将conda转换为32位环境
set CONDA_FORCE_32BIT=1
# 创建conda环境
conda create -n env_name python=3.7
# 进入conda环境
conda activate env_name
# 下载依赖包
conda install numpy ninja pyyaml mkl mkl-include setuptools cmake cffi typing
# 设置是否使用显卡,这里我设置为0,代表不使用显卡
set USE_CUDA=0
# 不适用ninja,使用ninja在编译时会发生问题,这里关闭ninja
set USE_NINJA=OFF
# (可选)是否编译test文件
set BUILD_TEST=False
# (可选)使用FBGEMM代替mkl-dnn编译
set USE_FBGEMM=ON
set CAFFE2=OFF
# 设置你生成的makefile的文件版本
set CMAKE_GENERATOR=Visual Studio 15 2017
# 设置使用的工具集
set CMAKE_GENERATOR_TOOLSET_VERSION=14.11
set DISTUTILS_USE_SDK=1
# 将编译环境转换为32位环境
for /f "usebackq tokens=*" %i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -version [15^,16^) -products * -latest -property installationPath`) do call "%i\VC\Auxiliary\Build\vcvarsall.bat" x86 -vcvars_ver=%CMAKE_GENERATOR_TOOLSET_VERSION%
# 编译libtorch
cd tools
python build_libtorch.py

我自己的设置如下:

set "CUDAHOSTCXX=C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64\cl.exe"
set USE_NINJA=OFF
set CMAKE_GENERATOR=Visual Studio 15 2017
set USE_FBGEMM=ON

3. 编译好后libtorch的位置

你的pytorch位置下的torch文件夹下的bin、lib、include、share文件夹

(pytorch) D:\documents\vs2015\Project\pytorch160\pytorch>python ./tools/build_libtorch.py
cmake -GVisual Studio 15 2017 -Ax64 -Thost=x64 -DBUILD_PYTHON=False -DBUILD_TEST=True -DCMAKE_BUILD_TYPE=Release -DCMAKE_GENERATOR=Visual Studio 15 2017 -DCMAKE_INSTALL_PREFIX=D:\documents\vs2015\Project\pytorch160\pytorch\torch -DCMAKE_PREFIX_PATH=D:\Anaconda3\envs\pytorch\Lib\site-packages -DJAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0_79 -DPYTHON_EXECUTABLE=D:\Anaconda3\envs\pytorch\python.exe -DPYTHON_INCLUDE_DIR=D:\Anaconda3\envs\pytorch\include -DUSE_FBGEMM=ON -DUSE_NINJA=OFF -DUSE_NUMPY=True D:\documents\vs2015\Project\pytorch160\pytorch
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19042.
-- The CXX compiler identification is MSVC 19.16.27043.0
-- The C compiler identification is MSVC 19.16.27043.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Not forcing any particular BLAS to be found
-- Performing Test COMPILER_WORKS
-- Performing Test COMPILER_WORKS - Success
-- Performing Test SUPPORT_GLIBCXX_USE_C99
-- Performing Test SUPPORT_GLIBCXX_USE_C99 - Success
-- Performing Test CAFFE2_EXCEPTION_PTR_SUPPORTED
-- Performing Test CAFFE2_EXCEPTION_PTR_SUPPORTED - Success
-- std::exception_ptr is supported.
-- Performing Test CAFFE2_NEED_TO_TURN_OFF_DEPRECATION_WARNING
-- Performing Test CAFFE2_NEED_TO_TURN_OFF_DEPRECATION_WARNING - Failed
-- Performing Test CAFFE2_COMPILER_SUPPORTS_AVX2_EXTENSIONS
-- Performing Test CAFFE2_COMPILER_SUPPORTS_AVX2_EXTENSIONS - Success
-- Current compiler supports avx2 extension. Will build perfkernels.
-- Performing Test CAFFE2_COMPILER_SUPPORTS_AVX512_EXTENSIONS
-- Performing Test CAFFE2_COMPILER_SUPPORTS_AVX512_EXTENSIONS - Success
-- Current compiler supports avx512f extension. Will build fbgemm.
-- Performing Test COMPILER_SUPPORTS_HIDDEN_VISIBILITY
-- Performing Test COMPILER_SUPPORTS_HIDDEN_VISIBILITY - Failed
-- Performing Test COMPILER_SUPPORTS_HIDDEN_INLINE_VISIBILITY
-- Performing Test COMPILER_SUPPORTS_HIDDEN_INLINE_VISIBILITY - Failed
-- Performing Test COMPILER_SUPPORTS_RDYNAMIC
-- Performing Test COMPILER_SUPPORTS_RDYNAMIC - Failed
-- Building using own protobuf under third_party per request.
-- Use custom protobuf build.
--
-- 3.11.4.0
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
-- Caffe2 protobuf include directory: $<BUILD_INTERFACE:D:/documents/vs2015/Project/pytorch160/pytorch/third_party/protobuf/src>$<INSTALL_INTERFACE:include>
-- Trying to find preferred BLAS backend of choice: MKL
-- MKL_THREADING = OMP
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of void*
-- Check size of void* - done
-- MKL_THREADING = OMP
CMake Warning at cmake/Dependencies.cmake:148 (message):
  MKL could not be found.  Defaulting to Eigen
Call Stack (most recent call first):
  CMakeLists.txt:469 (include)


CMake Warning at cmake/Dependencies.cmake:172 (message):
  Preferred BLAS (MKL) cannot be found, now searching for a general BLAS
  library
Call Stack (most recent call first):
  CMakeLists.txt:469 (include)


-- MKL_THREADING = OMP
-- Checking for [mkl_intel_lp64 - mkl_intel_thread - mkl_core - libiomp5md]
--   Library mkl_intel_lp64: not found
-- Checking for [mkl_intel - mkl_intel_thread - mkl_core - libiomp5md]
--   Library mkl_intel: not found
-- Checking for [mkl_intel_lp64 - mkl_intel_thread - mkl_core]
--   Library mkl_intel_lp64: not found
-- Checking for [mkl_intel - mkl_intel_thread - mkl_core]
--   Library mkl_intel: not found
-- Checking for [mkl_intel_lp64 - mkl_sequential - mkl_core]
--   Library mkl_intel_lp64: not found
-- Checking for [mkl_intel - mkl_sequential - mkl_core]
--   Library mkl_intel: not found
-- Checking for [mkl_intel_lp64 - mkl_core - libiomp5md - pthread]
--   Library mkl_intel_lp64: not found
-- Checking for [mkl_intel - mkl_core - libiomp5md - pthread]
--   Library mkl_intel: not found
-- Checking for [mkl_intel_lp64 - mkl_core - pthread]
--   Library mkl_intel_lp64: not found
-- Checking for [mkl_intel - mkl_core - pthread]
--   Library mkl_intel: not found
-- Checking for [mkl - guide - pthread - m]
--   Library mkl: not found
-- MKL library not found
-- Checking for [Accelerate]
--   Library Accelerate: BLAS_Accelerate_LIBRARY-NOTFOUND
-- Checking for [vecLib]
--   Library vecLib: BLAS_vecLib_LIBRARY-NOTFOUND
-- Checking for [openblas]
--   Library openblas: BLAS_openblas_LIBRARY-NOTFOUND
-- Checking for [openblas - pthread]
--   Library openblas: BLAS_openblas_LIBRARY-NOTFOUND
-- Checking for [libopenblas]
--   Library libopenblas: BLAS_libopenblas_LIBRARY-NOTFOUND
-- Checking for [goto2 - gfortran]
--   Library goto2: BLAS_goto2_LIBRARY-NOTFOUND
-- Checking for [goto2 - gfortran - pthread]
--   Library goto2: BLAS_goto2_LIBRARY-NOTFOUND
-- Checking for [acml - gfortran]
--   Library acml: BLAS_acml_LIBRARY-NOTFOUND
-- Checking for [blis]
--   Library blis: BLAS_blis_LIBRARY-NOTFOUND
-- Checking for [ptf77blas - atlas - gfortran]
--   Library ptf77blas: BLAS_ptf77blas_LIBRARY-NOTFOUND
-- Checking for [blas]
--   Library blas: BLAS_blas_LIBRARY-NOTFOUND
-- Cannot find a library with BLAS API. Not using BLAS.
CMake Warning at cmake/Dependencies.cmake:226 (message):
  Target platform "Windows" is not supported in {Q/X}NNPACK.  Supported
  platforms are Android, iOS, Linux, and macOS.  Turn this warning off by
  USE_{Q/X}NNPACK=OFF.
Call Stack (most recent call first):
  CMakeLists.txt:469 (include)


-- Found PythonInterp: D:/Anaconda3/envs/pytorch/python.exe (found version "3.7.10")
-- Found Git: C:/Program Files (x86)/Git/cmd/git.exe (found version "2.16.1.windows.3")
-- git Version: v1.4.0-505be96a
-- Version: 1.4.0
-- Performing Test HAVE_STD_REGEX
-- Performing Test HAVE_STD_REGEX
-- Performing Test HAVE_STD_REGEX -- success
-- Performing Test HAVE_GNU_POSIX_REGEX
-- Performing Test HAVE_GNU_POSIX_REGEX
-- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile
-- Performing Test HAVE_POSIX_REGEX
-- Performing Test HAVE_POSIX_REGEX
-- Performing Test HAVE_POSIX_REGEX -- failed to compile
-- Performing Test HAVE_STEADY_CLOCK
-- Performing Test HAVE_STEADY_CLOCK
-- Performing Test HAVE_STEADY_CLOCK -- success
-- Performing Test COMPILER_SUPPORTS_AVX512
-- Performing Test COMPILER_SUPPORTS_AVX512 - Success
-- MKL_THREADING = OMP
-- MKL_THREADING = OMP
-- MKL_THREADING = OMP
-- MKL_THREADING = OMP
CMake Warning (dev) at D:/Anaconda3/envs/pytorch/Lib/site-packages/cmake/data/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:273 (message):
  The package name passed to `find_package_handle_standard_args` (OpenMP_C)
  does not match the name of the calling package (OpenMP).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/Modules/FindOpenMP.cmake:565 (find_package_handle_standard_args)
  third_party/fbgemm/CMakeLists.txt:59 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found OpenMP_C: -openmp (found version "2.0")
CMake Warning (dev) at D:/Anaconda3/envs/pytorch/Lib/site-packages/cmake/data/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:273 (message):
  The package name passed to `find_package_handle_standard_args` (OpenMP_CXX)
  does not match the name of the calling package (OpenMP).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/Modules/FindOpenMP.cmake:565 (find_package_handle_standard_args)
  third_party/fbgemm/CMakeLists.txt:59 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found OpenMP_CXX: -openmp (found version "2.0")
-- Found OpenMP: TRUE (found version "2.0")
CMake Warning at third_party/fbgemm/CMakeLists.txt:61 (message):
  OpenMP found! OpenMP_C_INCLUDE_DIRS =


CMake Warning at third_party/fbgemm/CMakeLists.txt:130 (message):
  ==========


CMake Warning at third_party/fbgemm/CMakeLists.txt:131 (message):
  CMAKE_BUILD_TYPE = Release


CMake Warning at third_party/fbgemm/CMakeLists.txt:132 (message):
  CMAKE_CXX_FLAGS_DEBUG is /MDd /Z7 /Ob0 /Od /RTC1 /w /MP /bigobj


CMake Warning at third_party/fbgemm/CMakeLists.txt:133 (message):
  CMAKE_CXX_FLAGS_RELEASE is /MD /O2 /Ob2 /DNDEBUG /w /MP /bigobj


CMake Warning at third_party/fbgemm/CMakeLists.txt:134 (message):
  ==========


** AsmJit Summary **
   ASMJIT_DIR=D:/documents/vs2015/Project/pytorch160/pytorch/third_party/fbgemm/third_party/asmjit
   ASMJIT_TEST=FALSE
   ASMJIT_TARGET_TYPE=SHARED
   ASMJIT_DEPS=
   ASMJIT_LIBS=asmjit
   ASMJIT_CFLAGS=
   ASMJIT_PRIVATE_CFLAGS=-MP;-GR-;-GF;-Zc:inline;-Zc:strictStrings;-Zc:threadSafeInit-;-W4
   ASMJIT_PRIVATE_CFLAGS_DBG=-GS
   ASMJIT_PRIVATE_CFLAGS_REL=-GS-;-O2;-Oi
-- Downloading PSimd to D:/documents/vs2015/Project/pytorch160/pytorch/build/confu-srcs/psimd (define PSIMD_SOURCE_DIR to avoid it)
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19042.
-- Configuring done
-- Generating done
-- Build files have been written to: D:/documents/vs2015/Project/pytorch160/pytorch/build/confu-deps/psimd-download
用于 .NET Framework 的 Microsoft (R) 生成引擎版本 15.9.21+g9802d43bc3
版权所有(C) Microsoft Corporation。保留所有权利。

  Creating directories for 'psimd'
  Building Custom Rule D:/documents/vs2015/Project/pytorch160/pytorch/build/confu-deps/psimd-download/CMakeLists.txt
  Performing download step (git clone) for 'psimd'
  -- Avoiding repeated git clone, stamp file is up to date: 'D:/documents/vs2015/Project/pytorch160/pytorch/build/confu-deps/psimd-download/psimd-prefix/src/psimd-stamp/psimd-gitclone-lastrun.txt'
  Performing update step for 'psimd'
  No patch step for 'psimd'
  No configure step for 'psimd'
  No build step for 'psimd'
  No install step for 'psimd'
  No test step for 'psimd'
  Completed 'psimd'
  Building Custom Rule D:/documents/vs2015/Project/pytorch160/pytorch/build/confu-deps/psimd-download/CMakeLists.txt
-- Using third party subdirectory Eigen.
-- Using third_party/pybind11.
-- pybind11 include dirs: D:/documents/vs2015/Project/pytorch160/pytorch/cmake/../third_party/pybind11/include
CMake Warning (dev) at D:/Anaconda3/envs/pytorch/Lib/site-packages/cmake/data/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:273 (message):
  The package name passed to `find_package_handle_standard_args` (OpenMP_C)
  does not match the name of the calling package (OpenMP).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/Modules/FindOpenMP.cmake:565 (find_package_handle_standard_args)
  cmake/Dependencies.cmake:1047 (find_package)
  CMakeLists.txt:469 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at D:/Anaconda3/envs/pytorch/Lib/site-packages/cmake/data/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:273 (message):
  The package name passed to `find_package_handle_standard_args` (OpenMP_CXX)
  does not match the name of the calling package (OpenMP).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/Modules/FindOpenMP.cmake:565 (find_package_handle_standard_args)
  cmake/Dependencies.cmake:1047 (find_package)
  CMakeLists.txt:469 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Adding OpenMP CXX_FLAGS: -openmp
-- No OpenMP library needs to be linked against
-- Found CUDA: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0 (found version "10.0")
-- Caffe2: CUDA detected: 10.0
-- Caffe2: CUDA nvcc is: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0/bin/nvcc.exe
-- Caffe2: CUDA toolkit directory: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0
-- Caffe2: Header version is: 10.0
-- Found CUDNN: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0/lib/x64/cudnn.lib
-- Found cuDNN: v7.6.5  (include: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0/include, library: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0/lib/x64/cudnn.lib)
-- Autodetected CUDA architecture(s):  7.5
-- Added CUDA NVCC flags for: -gencode;arch=compute_75,code=sm_75
-- Could NOT find CUB (missing: CUB_INCLUDE_DIR)
CMake Warning at cmake/Dependencies.cmake:1334 (message):
  Metal is only used in ios builds.
Call Stack (most recent call first):
  CMakeLists.txt:469 (include)


Generated: D:/documents/vs2015/Project/pytorch160/pytorch/build/third_party/onnx/onnx/onnx_onnx_torch-ml.proto
Generated: D:/documents/vs2015/Project/pytorch160/pytorch/build/third_party/onnx/onnx/onnx-operators_onnx_torch-ml.proto
--
-- ******** Summary ********
--   CMake version         : 3.18.4
--   CMake command         : D:/Anaconda3/envs/pytorch/Lib/site-packages/cmake/data/bin/cmake.exe
--   System                : Windows
--   C++ compiler          : C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe
--   C++ compiler version  : 19.16.27043.0
--   CXX flags             : /DWIN32 /D_WINDOWS /GR /EHsc /w /MP /bigobj -openmp
--   Build type            : Release
--   Compile definitions   : ONNX_ML=1;ONNXIFI_ENABLE_EXT=1
--   CMAKE_PREFIX_PATH     : D:\Anaconda3\envs\pytorch\Lib\site-packages;C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0
--   CMAKE_INSTALL_PREFIX  : D:/documents/vs2015/Project/pytorch160/pytorch/torch
--   CMAKE_MODULE_PATH     : D:/documents/vs2015/Project/pytorch160/pytorch/cmake/Modules;D:/documents/vs2015/Project/pytorch160/pytorch/cmake/public/../Modules_CUDA_fix
--
--   ONNX version          : 1.7.0
--   ONNX NAMESPACE        : onnx_torch
--   ONNX_BUILD_TESTS      : OFF
--   ONNX_BUILD_BENCHMARKS : OFF
--   ONNX_USE_LITE_PROTO   : OFF
--   ONNXIFI_DUMMY_BACKEND : OFF
--   ONNXIFI_ENABLE_EXT    : OFF
--
--   Protobuf compiler     :
--   Protobuf includes     :
--   Protobuf libraries    :
--   BUILD_ONNX_PYTHON     : OFF
--
-- ******** Summary ********
--   CMake version         : 3.18.4
--   CMake command         : D:/Anaconda3/envs/pytorch/Lib/site-packages/cmake/data/bin/cmake.exe
--   System                : Windows
--   C++ compiler          : C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe
--   C++ compiler version  : 19.16.27043.0
--   CXX flags             : /DWIN32 /D_WINDOWS /GR /EHsc /w /MP /bigobj -openmp
--   Build type            : Release
--   Compile definitions   : ONNX_ML=1;ONNXIFI_ENABLE_EXT=1
--   CMAKE_PREFIX_PATH     : D:\Anaconda3\envs\pytorch\Lib\site-packages;C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0
--   CMAKE_INSTALL_PREFIX  : D:/documents/vs2015/Project/pytorch160/pytorch/torch
--   CMAKE_MODULE_PATH     : D:/documents/vs2015/Project/pytorch160/pytorch/cmake/Modules;D:/documents/vs2015/Project/pytorch160/pytorch/cmake/public/../Modules_CUDA_fix
--
--   ONNX version          : 1.4.1
--   ONNX NAMESPACE        : onnx_torch
--   ONNX_BUILD_TESTS      : OFF
--   ONNX_BUILD_BENCHMARKS : OFF
--   ONNX_USE_LITE_PROTO   : OFF
--   ONNXIFI_DUMMY_BACKEND : OFF
--
--   Protobuf compiler     :
--   Protobuf includes     :
--   Protobuf libraries    :
--   BUILD_ONNX_PYTHON     : OFF
-- Found CUDA with FP16 support, compiling with torch.cuda.HalfTensor
-- Adding -DNDEBUG to compile flags
-- MAGMA not found. Compiling without MAGMA support
-- Could not find hardware support for NEON on this machine.
-- No OMAP3 processor on this machine.
-- No OMAP4 processor on this machine.
-- Looking for cpuid.h
-- Looking for cpuid.h - not found
-- Performing Test NO_GCC_EBX_FPIC_BUG
Traceback (most recent call last):
  File "d:\anaconda3\envs\pytorch\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "d:\anaconda3\envs\pytorch\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\Anaconda3\envs\pytorch\Scripts\cmake.exe\__main__.py", line 7, in <module>
  File "d:\anaconda3\envs\pytorch\lib\site-packages\cmake\__init__.py", line 46, in cmake
    raise SystemExit(_program('cmake', sys.argv[1:]))
  File "d:\anaconda3\envs\pytorch\lib\site-packages\cmake\__init__.py", line 42, in _program
    return subprocess.call([os.path.join(CMAKE_BIN_DIR, name)] + args)
  File "d:\anaconda3\envs\pytorch\lib\subprocess.py", line 341, in call
    return p.wait(timeout=timeout)
  File "d:\anaconda3\envs\pytorch\lib\subprocess.py", line 1019, in wait
    return self._wait(timeout=timeout)
  File "d:\anaconda3\envs\pytorch\lib\subprocess.py", line 1259, in _wait
    timeout_millis)
KeyboardInterrupt
Traceback (most recent call last):
  File "./tools/build_libtorch.py", line 23, in <module>
    rerun_cmake=True, cmake_only=False, cmake=CMake())
  File "D:\documents\vs2015\Project\pytorch160\pytorch\tools\build_pytorch_libs.py", line 59, in build_caffe2
    rerun_cmake)
  File "D:\documents\vs2015\Project\pytorch160\pytorch\tools\setup_helpers\cmake.py", line 329, in generate
    self.run(args, env=my_env)
  File "D:\documents\vs2015\Project\pytorch160\pytorch\tools\setup_helpers\cmake.py", line 141, in run
    check_call(command, cwd=self.build_dir, env=env)
  File "D:\Anaconda3\envs\pytorch\lib\subprocess.py", line 358, in check_call
    retcode = call(*popenargs, **kwargs)
  File "D:\Anaconda3\envs\pytorch\lib\subprocess.py", line 341, in call
    return p.wait(timeout=timeout)
  File "D:\Anaconda3\envs\pytorch\lib\subprocess.py", line 1019, in wait
    return self._wait(timeout=timeout)
  File "D:\Anaconda3\envs\pytorch\lib\subprocess.py", line 1259, in _wait
    timeout_millis)
KeyboardInterrupt

4、支持不同的GPU算力

 因为https://blog.csdn.net/juluwangriyue/article/details/108423613中提到的方法已经不能使用,改用下面这个了。

set TORCH_CUDA_ARCH_LIST="3.5 5.2 6.0 6.1 7.5"

参考:https://discuss.pytorch.org/t/a-script-to-install-both-pytorch-2-0-gpu-and-cpu-versions/7009

上面的设置没有尝试通过,以后可以继续尝试。

下面的方法是使用的cmake+vs2017编译的。

下面是CMakeLists.txt修改前

CMakeLists.txt修改后

 

参考:windwos源码编译libtorch(win10+32bit+libtorch)

参考:https://github.com/pytorch/pytorch/tree/v1.6.0#from-source

 

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

落花逐流水

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值