Skip to content

Commit 3be5033

Browse files
authored
Upgrade to libtorch v1.8.0 in CMake scripts and Dockerfile, update CUDA version in colab notebook, update readme. (prabhuomkar#78)
1 parent 6414c4f commit 3be5033

File tree

5 files changed

+91
-224
lines changed

5 files changed

+91
-224
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
77
option(DOWNLOAD_DATASETS "Automatically download required datasets at build-time." ON)
88
option(CREATE_SCRIPTMODULES "Automatically create all required scriptmodule files at build-time (requires python3)." OFF)
99

10-
set(PYTORCH_VERSION "1.7.0")
10+
set(PYTORCH_VERSION "1.8.0")
1111

1212
find_package(Torch ${PYTORCH_VERSION} EXACT QUIET PATHS "${CMAKE_SOURCE_DIR}/libtorch")
1313

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ RUN curl --silent --show-error --location --output ~/miniconda.sh https://repo.a
3131

3232
FROM conda AS conda-installs
3333
# Install pytorch for CPU and torchvision.
34-
ARG PYTORCH_VERSION=1.6.0
35-
ARG TORCHVISION_VERSION=0.7.0
34+
ARG PYTORCH_VERSION=1.8.0
35+
ARG TORCHVISION_VERSION=0.9.0
3636
ENV NO_CUDA=1
3737
RUN conda install pytorch==${PYTORCH_VERSION} torchvision==${TORCHVISION_VERSION} cpuonly -y -c pytorch && conda clean -ya
3838

README.md

+6-6
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.7.0-ee4c2c">
9+
<img src="https://img.shields.io/badge/libtorch-1.8.0-ee4c2c">
1010
<img src="https://img.shields.io/badge/cmake-3.14-064f8d">
1111
</p>
1212

1313

14-
| OS (Compiler)\\LibTorch | 1.7.0 | nightly |
14+
| OS (Compiler)\\LibTorch | 1.8.0 | 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) | |
@@ -58,7 +58,7 @@ This repository provides tutorial code in C++ for deep learning researchers to l
5858

5959
1. [C++](http://www.cplusplus.com/doc/tutorial/introduction/)
6060
2. [CMake](https://cmake.org/download/) (minimum version 3.14)
61-
3. [LibTorch v1.7.0](https://pytorch.org/cppdocs/installing.html)
61+
3. [LibTorch v1.8.0](https://pytorch.org/cppdocs/installing.html)
6262
4. [Conda](https://docs.conda.io/projects/conda/en/latest/user-guide/install/download.html)
6363

6464

@@ -95,7 +95,7 @@ Some useful options:
9595

9696
| Option | Default | Description |
9797
| :------------- |:------------|-----:|
98-
| `-D CUDA_V=(9.2 [Linux only]\|10.1\|10.2\|11.0\|none)` | `none` | Download LibTorch for a CUDA version (`none` = download CPU version). |
98+
| `-D CUDA_V=(\|10.2\|11.1\|none)` | `none` | Download LibTorch for a CUDA version (`none` = download CPU version). |
9999
| `-D DOWNLOAD_DATASETS=(OFF\|ON)` | `ON` | Download required datasets during build (only if they do not already exist in `pytorch-cpp/data`). |
100100
|`-D CREATE_SCRIPTMODULES=(OFF\|ON)` | `OFF` | Create all required scriptmodule files for prelearned models / weights during build. Requires installed python3 with pytorch and torchvision. |
101101
| `-D CMAKE_PREFIX_PATH=path/to/libtorch/share/cmake/Torch` | `<empty>` | Skip the downloading of LibTorch and use your own local version (see [Requirements](#requirements)) instead. |
@@ -121,14 +121,14 @@ cmake -B build \
121121
<summary><b>Example Windows</b></summary>
122122

123123
##### Aim
124-
* Automatically download LibTorch for CUDA 10.2 and all necessary datasets.
124+
* Automatically download LibTorch for CUDA 11.1 and all necessary datasets.
125125
* Do not create scriptmodule files.
126126

127127
##### Command
128128
```bash
129129
cmake -B build \
130130
-A x64 \
131-
-D CUDA_V=10.2
131+
-D CUDA_V=11.1
132132
```
133133
</details>
134134

cmake/fetch_libtorch.cmake

+4-12
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,23 @@ cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
22

33
include(FetchContent)
44

5-
set(CUDA_V "none" CACHE STRING "Determines libtorch CUDA version to download (9.2 [Linux only], 10.1, 10.2 or 11.0).")
5+
set(CUDA_V "none" CACHE STRING "Determines libtorch CUDA version to download (10.2, 11.1 or none).")
66

77
if(${CUDA_V} STREQUAL "none")
88
set(LIBTORCH_DEVICE "cpu")
9-
elseif(${CUDA_V} STREQUAL "9.2")
10-
set(LIBTORCH_DEVICE "cu92")
11-
elseif(${CUDA_V} STREQUAL "10.1")
12-
set(LIBTORCH_DEVICE "cu101")
139
elseif(${CUDA_V} STREQUAL "10.2")
1410
set(LIBTORCH_DEVICE "cu102")
15-
elseif(${CUDA_V} STREQUAL "11.0")
16-
set(LIBTORCH_DEVICE "cu110")
11+
elseif(${CUDA_V} STREQUAL "11.1")
12+
set(LIBTORCH_DEVICE "cu111")
1713
else()
18-
message(FATAL_ERROR "Invalid CUDA version specified, must be 9.2 [Linux only], 10.1, 10.2, 11.0 or none!")
14+
message(FATAL_ERROR "Invalid CUDA version specified, must be 10.2, 11.1 or none!")
1915
endif()
2016

2117
if(NOT ${LIBTORCH_DEVICE} STREQUAL "cu102")
2218
set(LIBTORCH_DEVICE_TAG "%2B${LIBTORCH_DEVICE}")
2319
endif()
2420

2521
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
26-
if(${LIBTORCH_DEVICE} STREQUAL "cu92")
27-
message(FATAL_ERROR "PyTorch ${PYTORCH_VERSION} does not support CUDA 9.2 on Windows. Please use CPU or upgrade to CUDA versions 10.1, 10.2 or 11.0.")
28-
endif()
29-
3022
set(LIBTORCH_URL "https://download.pytorch.org/libtorch/${LIBTORCH_DEVICE}/libtorch-win-shared-with-deps-${PYTORCH_VERSION}${LIBTORCH_DEVICE_TAG}.zip")
3123
set(CMAKE_BUILD_TYPE "Release")
3224
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")

0 commit comments

Comments
 (0)