Skip to content

Commit

Permalink
Upgraded pytorch to 2.3.0 latest version (#123)
Browse files Browse the repository at this point in the history
* Upgraded pytorch to 2.3.0 latest version

* updates to CI

* Update macOS download link

* Updated macOS runner

* Correct the configure step

* Updated minimum cmake requirement to be 3.19

* Remove explicit arch for macOS runner

* Updated README poster

* Updated torchvision version in Dockerfile
  • Loading branch information
prabhuomkar committed May 6, 2024
1 parent bc8858c commit 511775f
Show file tree
Hide file tree
Showing 41 changed files with 61 additions and 61 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ on:

jobs:
build-mac:
name: "Macos 11.7 Xcode (Clang)"
runs-on: macos-11
name: "macOS 14.4.1 arm64 Xcode (Clang)"
runs-on: macos-14
strategy:
matrix:
xcode: [11.7, 12.4, 13.2.1]
xcode: [14.3.1, 15.3]
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up CMake
uses: jwlawson/actions-setup-cmake@v1.13
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.14.0'
cmake-version: '3.19.0'
- name: Set up Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/build_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ on:

jobs:
build-ubuntu:
name: "Ubuntu 20.04 GCC"
runs-on: ubuntu-20.04
name: "Ubuntu 22.04 GCC"
runs-on: ubuntu-22.04
strategy:
matrix:
gcc: [9, 10, 11]
gcc: [11, 12, 13]
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up CMake
uses: jwlawson/actions-setup-cmake@v1.13
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.14.0'
cmake-version: '3.19.0'
- name: Set up GCC
uses: egor-tensin/setup-gcc@v1
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- {
name: Windows MSVC 2019,
os: windows-2019,
cmake: '3.14.0'
cmake: '3.19.0'
}
- {
name: Windows MSVC 2022,
Expand All @@ -35,9 +35,9 @@ jobs:
}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up CMake
uses: jwlawson/actions-setup-cmake@v1.13
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: ${{ matrix.config.cmake }}
- name: Cpplint
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

project(pytorch-cpp VERSION 1.0.0 LANGUAGES CXX)

Expand All @@ -7,7 +7,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
option(DOWNLOAD_DATASETS "Automatically download required datasets at build-time." ON)
option(CREATE_SCRIPTMODULES "Automatically create all required scriptmodule files at build-time (requires python3)." OFF)

set(PYTORCH_VERSION "2.1.1")
set(PYTORCH_VERSION "2.3.0")
set(PYTORCH_MIN_VERSION "1.12.0")

find_package(Torch QUIET PATHS "${CMAKE_SOURCE_DIR}/libtorch")
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ RUN curl --silent --show-error --location --output ~/miniconda.sh https://repo.a

FROM conda AS conda-installs
# Install pytorch for CPU and torchvision.
ARG PYTORCH_VERSION=2.1.1
ARG TORCHVISION_VERSION=0.16.1
ARG PYTORCH_VERSION=2.3.0
ARG TORCHVISION_VERSION=0.18.0
ENV NO_CUDA=1
RUN conda install pytorch==${PYTORCH_VERSION} torchvision==${TORCHVISION_VERSION} cpuonly -y -c pytorch && conda clean -ya

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<h1 align="center">
<img src="images/pytorch_cpp.png" width="50%">
<img src="images/pytorch_cpp.jpg" width="50%">
</h1>
<p align="center">
C++ Implementation of PyTorch Tutorials for Everyone
<br />
<img src="https://img.shields.io/github/license/prabhuomkar/pytorch-cpp">
<img src="https://img.shields.io/badge/libtorch-2.1.1-ee4c2c">
<img src="https://img.shields.io/badge/cmake-3.14-064f8d">
<img src="https://img.shields.io/badge/libtorch-2.3.0-ee4c2c">
<img src="https://img.shields.io/badge/cmake-3.19-064f8d">
</p>


| OS (Compiler)\\LibTorch | 2.1.1 |
| OS (Compiler)\\LibTorch | 2.3.0 |
| :--------------------- | :--------------------------------------------------------------------------------------------------- |
| macOS (clang 11, 12, 13) | [![Status](https://github.com/prabhuomkar/pytorch-cpp/actions/workflows/build_macos.yml/badge.svg?branch=master)](https://github.com/prabhuomkar/pytorch-cpp/actions?query=workflow%3Aci-build-macos) |
| Linux (gcc 9, 10, 11) | [![Status](https://github.com/prabhuomkar/pytorch-cpp/actions/workflows/build_ubuntu.yml/badge.svg?branch=master)](https://github.com/prabhuomkar/pytorch-cpp/actions?query=workflow%3Aci-build-ubuntu) |
Expand Down Expand Up @@ -51,8 +51,8 @@ This repository provides tutorial code in C++ for deep learning researchers to l
## Requirements

1. [C++-17](http://www.cplusplus.com/doc/tutorial/introduction/) compatible compiler
2. [CMake](https://cmake.org/download/) (minimum version 3.14)
3. [LibTorch version >= 1.12.0 and <= 2.1.1](https://pytorch.org/cppdocs/installing.html)
2. [CMake](https://cmake.org/download/) (minimum version 3.19)
3. [LibTorch version >= 1.12.0 and <= 2.3.0](https://pytorch.org/cppdocs/installing.html)
4. [Conda](https://docs.conda.io/projects/conda/en/latest/user-guide/install/download.html)


Expand Down
2 changes: 1 addition & 1 deletion cmake/check_files.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

function(check_files BASE_DIR FILES_TO_CHECK FILE_MD5S MISSING_FILES)
foreach(FILE_TO_CHECK ${${FILES_TO_CHECK}})
Expand Down
2 changes: 1 addition & 1 deletion cmake/copy_torch_dlls.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

function(copy_torch_dlls TARGET_NAME)
# According to https://github.com/pytorch/pytorch/issues/25457
Expand Down
2 changes: 1 addition & 1 deletion cmake/cpplint.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

find_program(CPPLINT cpplint)

Expand Down
2 changes: 1 addition & 1 deletion cmake/create_torch_dll_hardlinks.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

file(GLOB TORCH_DLLS "${TORCH_INSTALL_PREFIX}/lib/*.dll")

Expand Down
2 changes: 1 addition & 1 deletion cmake/fetch_cifar10.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

function(fetch_cifar10 DATA_DIR)
set(CIFAR_DIR "${DATA_DIR}/cifar10")
Expand Down
2 changes: 1 addition & 1 deletion cmake/fetch_datasets.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

include(${CMAKE_CURRENT_LIST_DIR}/fetch_mnist.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/fetch_cifar10.cmake)
Expand Down
2 changes: 1 addition & 1 deletion cmake/fetch_flickr8k.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

function(fetch_flickr8k DATA_DIR)
set(FLICKR8K_DIR "${DATA_DIR}/flickr_8k")
Expand Down
2 changes: 1 addition & 1 deletion cmake/fetch_imagenette.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

function(fetch_imagenette DATA_DIR)
set(IMAGENETTE_DIR "${DATA_DIR}/imagenette2-160")
Expand Down
4 changes: 2 additions & 2 deletions cmake/fetch_libtorch.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

include(FetchContent)

Expand Down Expand Up @@ -33,7 +33,7 @@ elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
message(WARNING "MacOS binaries do not support CUDA, will download CPU version instead.")
set(LIBTORCH_DEVICE "cpu")
endif()
set(LIBTORCH_URL "https://download.pytorch.org/libtorch/cpu/libtorch-macos-${PYTORCH_VERSION}.zip")
set(LIBTORCH_URL "https://download.pytorch.org/libtorch/cpu/libtorch-macos-arm64-${PYTORCH_VERSION}.zip")
else()
message(FATAL_ERROR "Unsupported CMake System Name '${CMAKE_SYSTEM_NAME}' (expected 'Windows', 'Linux' or 'Darwin')")
endif()
Expand Down
2 changes: 1 addition & 1 deletion cmake/fetch_mnist.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

function(fetch_mnist DATA_DIR)
set(MNIST_DOWNLOAD_DIR "${DATA_DIR}/mnist/download")
Expand Down
2 changes: 1 addition & 1 deletion cmake/fetch_neural_style_transfer_images.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

function(fetch_neural_style_transfer_imagers DATA_DIR)
set(NEURAL_STYLE_TRANSFER_IMAGES_DIR
Expand Down
2 changes: 1 addition & 1 deletion cmake/fetch_penntreebank.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

function(fetch_penntreebank DATA_DIR)
set(PENNTREEBANK_DIR "${DATA_DIR}/penntreebank")
Expand Down
2 changes: 1 addition & 1 deletion cmake/find_gz_extractor.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

# Find program that can extract .gz files.
# Based on: https://github.com/Amber-MD/cmake-buildscripts/blob/master/gzip.cmake
Expand Down
2 changes: 1 addition & 1 deletion extern/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

project(extern VERSION 1.0.0 LANGUAGES CXX)

Expand Down
Binary file added images/pytorch_cpp.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/pytorch_cpp.png
Binary file not shown.
6 changes: 3 additions & 3 deletions notebooks/pytorch_cpp_colab_notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@
"!rm -rf deps\n",
"!mkdir deps\n",
"%cd /content/deps\n",
"!wget --no-check-certificate https://www.cmake.org/files/v3.14/cmake-3.14.0-Linux-x86_64.tar.gz\n",
"!tar -xvf cmake-3.14.0-Linux-x86_64.tar.gz > /dev/null\n",
"%mv cmake-3.14.0-Linux-x86_64 cmake-install\n",
"!wget --no-check-certificate https://www.cmake.org/files/v3.19/cmake-3.19.0-Linux-x86_64.tar.gz\n",
"!tar -xvf cmake-3.19.0-Linux-x86_64.tar.gz > /dev/null\n",
"%mv cmake-3.19.0-Linux-x86_64 cmake-install\n",
"old_path = %env PATH\n",
"new_path = \"/content/deps/cmake-install:/content/deps/cmake-install/bin:\" + old_path\n",
"%env PATH={new_path}\n",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

project(generative-adversarial-network VERSION 1.0.0 LANGUAGES CXX)

Expand Down
2 changes: 1 addition & 1 deletion tutorials/advanced/image_captioning/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

project(image-captioning VERSION 1.0.0 LANGUAGES CXX)

Expand Down
2 changes: 1 addition & 1 deletion tutorials/advanced/neural_style_transfer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

project(neural-style-transfer VERSION 1.0.0 LANGUAGES CXX)

Expand Down
2 changes: 1 addition & 1 deletion tutorials/advanced/variational_autoencoder/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

project(variational-autoencoder VERSION 1.0.0 LANGUAGES CXX)

Expand Down
2 changes: 1 addition & 1 deletion tutorials/basics/feedforward_neural_network/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

project(feedforward-neural-network VERSION 1.0.0 LANGUAGES CXX)

Expand Down
2 changes: 1 addition & 1 deletion tutorials/basics/linear_regression/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

project(linear-regression VERSION 1.0.0 LANGUAGES CXX)

Expand Down
2 changes: 1 addition & 1 deletion tutorials/basics/logistic_regression/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

project(logistic-regression VERSION 1.0.0 LANGUAGES CXX)

Expand Down
2 changes: 1 addition & 1 deletion tutorials/basics/pytorch_basics/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

project(pytorch-basics VERSION 1.0.0 LANGUAGES CXX)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

project(bidirectional-recurrent-neural-network VERSION 1.0.0 LANGUAGES CXX)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

project(convolutional-neural-network VERSION 1.0.0 LANGUAGES CXX)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

project(deep-residual-network VERSION 1.0.0 LANGUAGES CXX)

Expand Down
2 changes: 1 addition & 1 deletion tutorials/intermediate/language_model/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

project(language-model VERSION 1.0.0 LANGUAGES CXX)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

project(recurrent-neural-network VERSION 1.0.0 LANGUAGES CXX)

Expand Down
2 changes: 1 addition & 1 deletion tutorials/popular/blitz/autograd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

project(autograd VERSION 1.0.0 LANGUAGES CXX)

Expand Down
2 changes: 1 addition & 1 deletion tutorials/popular/blitz/neural_networks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

project(neural-networks VERSION 1.0.0 LANGUAGES CXX)

Expand Down
2 changes: 1 addition & 1 deletion tutorials/popular/blitz/tensors/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

project(tensors VERSION 1.0.0 LANGUAGES CXX)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

project(training-a-classifier VERSION 1.0.0 LANGUAGES CXX)

Expand Down
2 changes: 1 addition & 1 deletion utils/image_io/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

project(image-io VERSION 1.0.0 LANGUAGES CXX)

Expand Down

0 comments on commit 511775f

Please sign in to comment.