Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Housekeeping and PyTorch Upgrade #125

Merged
merged 2 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 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 14.4.1 arm64 Xcode (Clang)"
name: "macOS 14 arm64 Xcode (Clang)"
runs-on: macos-14
strategy:
matrix:
xcode: [14.3.1, 15.3]
xcode: [15.3, 16.1]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up CMake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.19.0'
cmake-version: '3.28.6'
- name: Set up Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
Expand Down
8 changes: 4 additions & 4 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 22.04 GCC"
runs-on: ubuntu-22.04
name: "Ubuntu 24.04 GCC"
runs-on: ubuntu-24.04
strategy:
matrix:
gcc: [11, 12, 13]
gcc: [13, 14]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up CMake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.19.0'
cmake-version: '3.28.6'
- name: Set up GCC
uses: egor-tensin/setup-gcc@v1
with:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/build_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ jobs:
strategy:
matrix:
config:
- {
name: Windows MSVC 2019,
os: windows-2019,
cmake: '3.19.0'
}
- {
name: Windows MSVC 2022,
os: windows-2022,
cmake: '3.24.2'
cmake: '3.28.6'
}
- {
name: Windows MSVC 2025,
os: windows-2025,
cmake: '3.28.6'
}
steps:
- name: Checkout
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.19 FATAL_ERROR)
cmake_minimum_required(VERSION 3.28.6 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.3.0")
set(PYTORCH_VERSION "2.6.0")
set(PYTORCH_MIN_VERSION "1.12.0")

find_package(Torch QUIET PATHS "${CMAKE_SOURCE_DIR}/libtorch")
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ 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.3.0
ARG PYTORCH_VERSION=2.6.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
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
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.3.0-ee4c2c">
<img src="https://img.shields.io/badge/cmake-3.19-064f8d">
<img src="https://img.shields.io/badge/libtorch-2.6.0-ee4c2c">
<img src="https://img.shields.io/badge/cmake-3.28.6-064f8d">
</p>


| OS (Compiler)\\LibTorch | 2.3.0 |
| OS (Compiler)\\LibTorch | 2.6.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) |
| Windows (msvc 2019, 2022) | [![Status](https://github.com/prabhuomkar/pytorch-cpp/actions/workflows/build_windows.yml/badge.svg?branch=master)](https://github.com/prabhuomkar/pytorch-cpp/actions?query=workflow%3Aci-build-windows) |
| macOS (clang 15, 16) | [![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 13, 14) | [![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) |
| Windows (msvc 2022, 2025) | [![Status](https://github.com/prabhuomkar/pytorch-cpp/actions/workflows/build_windows.yml/badge.svg?branch=master)](https://github.com/prabhuomkar/pytorch-cpp/actions?query=workflow%3Aci-build-windows) |

## Table of Contents

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.19)
3. [LibTorch version >= 1.12.0 and <= 2.3.0](https://pytorch.org/cppdocs/installing.html)
2. [CMake](https://cmake.org/download/) (minimum version 3.28.6)
3. [LibTorch version >= 1.12.0 and <= 2.6.0](https://pytorch.org/cppdocs/installing.html)
4. [Conda](https://docs.conda.io/projects/conda/en/latest/user-guide/install/download.html)


Expand Down Expand Up @@ -89,7 +89,7 @@ Some useful options:

| Option | Default | Description |
| :------------- |:------------|-----:|
| `-D CUDA_V=(11.8\|12.1\|none)` | `none` | Download LibTorch for a CUDA version (`none` = download CPU version). |
| `-D CUDA_V=(11.8\|12.4\|12.6\|none)` | `none` | Download LibTorch for a CUDA version (`none` = download CPU version). |
| `-D LIBTORCH_DOWNLOAD_BUILD_TYPE=(Release\|Debug)` | `Release` | Determines which libtorch build type version to download (only relevant on **Windows**).|
| `-D DOWNLOAD_DATASETS=(OFF\|ON)` | `ON` | Download required datasets during build (only if they do not already exist in `pytorch-cpp/data`). |
|`-D CREATE_SCRIPTMODULES=(OFF\|ON)` | `OFF` | Create all required scriptmodule files for prelearned models / weights during build. Requires installed python3 with pytorch and torchvision. |
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.19 FATAL_ERROR)
cmake_minimum_required(VERSION 3.28.6 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.19 FATAL_ERROR)
cmake_minimum_required(VERSION 3.28.6 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.19 FATAL_ERROR)
cmake_minimum_required(VERSION 3.28.6 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.19 FATAL_ERROR)
cmake_minimum_required(VERSION 3.28.6 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.19 FATAL_ERROR)
cmake_minimum_required(VERSION 3.28.6 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.19 FATAL_ERROR)
cmake_minimum_required(VERSION 3.28.6 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.19 FATAL_ERROR)
cmake_minimum_required(VERSION 3.28.6 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.19 FATAL_ERROR)
cmake_minimum_required(VERSION 3.28.6 FATAL_ERROR)

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

include(FetchContent)

set(CUDA_V "none" CACHE STRING "Determines libtorch CUDA version to download (11.8, 12.1 or none).")
set(CUDA_V "none" CACHE STRING "Determines libtorch CUDA version to download (11.8, 12.4, 12.6 or none).")

if(${CUDA_V} STREQUAL "none")
set(LIBTORCH_DEVICE "cpu")
elseif(${CUDA_V} STREQUAL "11.8")
set(LIBTORCH_DEVICE "cu118")
elseif(${CUDA_V} STREQUAL "12.1")
set(LIBTORCH_DEVICE "cu121")
elseif(${CUDA_V} STREQUAL "12.4")
set(LIBTORCH_DEVICE "cu124")
elseif(${CUDA_V} STREQUAL "12.6")
set(LIBTORCH_DEVICE "cu126")
else()
message(FATAL_ERROR "Invalid CUDA version specified, must be 11.8, 12.1 or none!")
message(FATAL_ERROR "Invalid CUDA version specified, must be 11.8, 12.4, 12.6 or none!")
endif()

if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
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.19 FATAL_ERROR)
cmake_minimum_required(VERSION 3.28.6 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.19 FATAL_ERROR)
cmake_minimum_required(VERSION 3.28.6 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.19 FATAL_ERROR)
cmake_minimum_required(VERSION 3.28.6 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.19 FATAL_ERROR)
cmake_minimum_required(VERSION 3.28.6 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.19 FATAL_ERROR)
cmake_minimum_required(VERSION 3.28.6 FATAL_ERROR)

project(extern VERSION 1.0.0 LANGUAGES CXX)

Expand Down
Loading