Skip to content

Commit 3d11667

Browse files
authored
Upgrade to libtorch v1.5.1 (#57)
* Upgrade to libtorch v1.5.1, force exact version match for libtorch in CMake * Update libtorch download links
1 parent da5d141 commit 3d11667

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
66

77
option(DOWNLOAD_DATASETS "Download datasets used in the tutorials." ON)
88

9-
find_package(Torch QUIET PATHS "${CMAKE_SOURCE_DIR}/libtorch")
9+
set(PYTORCH_VERSION "1.5.1")
10+
11+
find_package(Torch ${PYTORCH_VERSION} EXACT QUIET PATHS "${CMAKE_SOURCE_DIR}/libtorch")
1012

1113
if(NOT Torch_FOUND)
1214
unset(Torch_FOUND)

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
<br />
77
<img src="https://img.shields.io/travis/prabhuomkar/pytorch-cpp">
88
<img src="https://img.shields.io/github/license/prabhuomkar/pytorch-cpp">
9-
<img src="https://img.shields.io/badge/libtorch-1.5-ee4c2c">
9+
<img src="https://img.shields.io/badge/libtorch-1.5.1-ee4c2c">
1010
<img src="https://img.shields.io/badge/cmake-3.14-064f8d">
1111
</p>
1212

1313

14-
| OS (Compiler)\\libtorch | 1.5 | nightly |
14+
| OS (Compiler)\\libtorch | 1.5.1 | nightly |
1515
| :---------------------: | :---------------------------------------------------------------------------------------------------: | :-----: |
1616
| macOS (clang 9.1) | ![Status](https://travis-matrix-badges.herokuapp.com/repos/prabhuomkar/pytorch-cpp/branches/master/1) | |
1717
| macOS (clang 10.0) | ![Status](https://travis-matrix-badges.herokuapp.com/repos/prabhuomkar/pytorch-cpp/branches/master/2) | |
@@ -31,7 +31,7 @@ This repository provides tutorial code in C++ for deep learning researchers to l
3131

3232
1. [C++](http://www.cplusplus.com/doc/tutorial/introduction/)
3333
2. [CMake](https://cmake.org/download/)
34-
3. [LibTorch v1.5.0](https://pytorch.org/cppdocs/installing.html)
34+
3. [LibTorch v1.5.1](https://pytorch.org/cppdocs/installing.html)
3535
4. [Conda](https://docs.conda.io/projects/conda/en/latest/user-guide/install/download.html)
3636

3737

@@ -70,7 +70,7 @@ Some useful options:
7070
| :------------- |:------------|-----:|
7171
| `-D CUDA_V=(9.2\|10.1\|10.2\|none)` | `none` | Download libtorch for a CUDA version (`none` = download CPU version). |
7272
| `-D DOWNLOAD_DATASETS=(OFF\|ON)` | `ON` | Download all datasets used in the tutorials. |
73-
| `-D CMAKE_PREFIX_PATH=path/to/libtorch/share/cmake/Torch` | `<empty>` | Skip the downloading of libtorch and use your own local version instead. |
73+
| `-D CMAKE_PREFIX_PATH=path/to/libtorch/share/cmake/Torch` | `<empty>` | Skip the downloading of libtorch and use your own local version (see Requirements) instead. |
7474
| `-D CMAKE_BUILD_TYPE=(Release\|Debug)` | `<empty>` (`Release` when downloading libtorch on Windows) | Set the build type (`Release` = compile with optimizations)|
7575

7676
#### Build

cmake/download_libtorch.cmake

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
22

33
include(FetchContent)
44

5-
set(CUDA_V "none" CACHE STRING "Determines cuda version to download (9.2 or 10.1).")
6-
set(PYTORCH_VERSION "1.5.0")
5+
set(CUDA_V "none" CACHE STRING "Determines libtorch CUDA version to download (9.2, 10.1 or 10.2).")
76

87
if(${CUDA_V} STREQUAL "none")
98
set(LIBTORCH_DEVICE "cpu")
@@ -17,25 +16,26 @@ else()
1716
message(FATAL_ERROR "Invalid CUDA version specified, must be 9.2, 10.1, 10.2 or none!")
1817
endif()
1918

19+
if(NOT ${LIBTORCH_DEVICE} STREQUAL "cu102")
20+
set(LIBTORCH_DEVICE_TAG "%2B${LIBTORCH_DEVICE}")
21+
endif()
22+
2023
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
21-
set(LIBTORCH_URL "https://download.pytorch.org/libtorch/${LIBTORCH_DEVICE}/libtorch-win-shared-with-deps-${PYTORCH_VERSION}.zip")
24+
set(LIBTORCH_URL "https://download.pytorch.org/libtorch/${LIBTORCH_DEVICE}/libtorch-win-shared-with-deps-${PYTORCH_VERSION}${LIBTORCH_DEVICE_TAG}.zip")
2225
set(CMAKE_BUILD_TYPE "Release")
2326
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
24-
if(${LIBTORCH_DEVICE} STREQUAL "cu101")
25-
set(LIBTORCH_URL "https://download.pytorch.org/libtorch/${LIBTORCH_DEVICE}/libtorch-shared-with-deps-${PYTORCH_VERSION}.zip")
26-
else()
27-
set(LIBTORCH_URL "https://download.pytorch.org/libtorch/${LIBTORCH_DEVICE}/libtorch-shared-with-deps-${PYTORCH_VERSION}%2B${LIBTORCH_DEVICE}.zip")
28-
endif()
27+
set(LIBTORCH_URL "https://download.pytorch.org/libtorch/${LIBTORCH_DEVICE}/libtorch-shared-with-deps-${PYTORCH_VERSION}${LIBTORCH_DEVICE_TAG}.zip")
2928
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
3029
if(NOT ${LIBTORCH_DEVICE} STREQUAL "cpu")
3130
message(WARNING "MacOS binaries do not support CUDA, will download CPU version instead.")
31+
set(LIBTORCH_DEVICE "cpu")
3232
endif()
3333
set(LIBTORCH_URL "https://download.pytorch.org/libtorch/cpu/libtorch-macos-${PYTORCH_VERSION}.zip")
3434
else()
3535
message(FATAL_ERROR "Unsupported CMake System Name '${CMAKE_SYSTEM_NAME}' (expected 'Windows', 'Linux' or 'Darwin')")
3636
endif()
3737

38-
if(${CUDA_V} STREQUAL "none")
38+
if(${LIBTORCH_DEVICE} STREQUAL "cpu")
3939
message(STATUS "Downloading libtorch version ${PYTORCH_VERSION} for CPU on ${CMAKE_SYSTEM_NAME} from ${LIBTORCH_URL}...")
4040
else()
4141
message(STATUS "Downloading libtorch version ${PYTORCH_VERSION} for CUDA ${CUDA_V} on ${CMAKE_SYSTEM_NAME} from ${LIBTORCH_URL}...")

0 commit comments

Comments
 (0)