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

Update to Pytorch 2.3.0 #1498

Merged
merged 18 commits into from
May 19, 2024
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
16 changes: 10 additions & 6 deletions .github/actions/deploy-ubuntu/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ runs:
fi
cd $HOME

# Free disk space by removing some unused system components
$SUDO rm -rf /usr/local/lib/android
$SUDO rm -rf /usr/share/dotnet

# Allocate a swapfile on Linux as it's not enabled by default. Needed for pytorch and mkl.
$SUDO fallocate -l 4GB /swapfile
$SUDO chmod 600 /swapfile
$SUDO mkswap /swapfile
$SUDO swapon /swapfile

mkdir -p .ccache
echo "max_size = 2.0G" > .ccache/ccache.conf
echo "hash_dir = false" >> .ccache/ccache.conf
Expand Down Expand Up @@ -230,12 +240,6 @@ runs:
curl -LO https://registrationcenter-download.intel.com/akdlm/IRC_NAS/86d6a4c1-c998-4c6b-9fff-ca004e9f7455/l_onemkl_p_2024.0.0.49673_offline.sh
$SUDO bash l_onemkl_p_2024.0.0.49673_offline.sh -s -a -s --eula accept
export MAVEN_OPTIONS="-Djavacpp.platform.compiler=clang++"

# Allocate a swapfile on Linux as it's not enabled by default
$SUDO fallocate -l 4GB /swapfile
$SUDO chmod 600 /swapfile
$SUDO mkswap /swapfile
$SUDO swapon /swapfile
fi

if [[ "$CI_DEPLOY_PLATFORM" == "linux-armhf" ]] && [[ "$CI_DEPLOY_MODULE" == "flycapture" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Build FFmpeg with zimg to enable zscale filter ([pull #1481](https://github.com/bytedeco/javacpp-presets/pull/1481))
* Enable PulseAudio support for FFmpeg on Linux ([pull #1472](https://github.com/bytedeco/javacpp-presets/pull/1472))
* Virtualize `btCollisionWorld`, `btOverlapFilterCallback`, `btOverlapCallback` from Bullet Physics SDK ([pull #1475](https://github.com/bytedeco/javacpp-presets/pull/1475))
* Upgrade presets for FFmpeg 7.0, DNNL 3.4.1, OpenBLAS 0.3.27, CPython 3.12.3, NumPy 1.26.4, SciPy 1.13.0, LLVM 18.1.4, libffi 3.4.6, PyTorch 2.2.2 ([pull #1466](https://github.com/bytedeco/javacpp-presets/pull/1466)), SentencePiece 0.2.0, TensorFlow Lite 2.16.1, TensorRT 10.0.1.6, Triton Inference Server 2.44.0, ONNX 1.16.0, ONNX Runtime 1.17.3, TVM 0.16.0, and their dependencies
* Upgrade presets for FFmpeg 7.0, DNNL 3.4.1, OpenBLAS 0.3.27, CPython 3.12.3, NumPy 1.26.4, SciPy 1.13.0, LLVM 18.1.4, libffi 3.4.6, PyTorch 2.3.0 ([pull #1466](https://github.com/bytedeco/javacpp-presets/pull/1466)), SentencePiece 0.2.0, TensorFlow Lite 2.16.1, TensorRT 10.0.1.6, Triton Inference Server 2.44.0, ONNX 1.16.0, ONNX Runtime 1.17.3, TVM 0.16.0, and their dependencies

### January 29, 2024 version 1.5.10
* Introduce `macosx-arm64` builds for PyTorch ([pull #1463](https://github.com/bytedeco/javacpp-presets/pull/1463))
Expand Down
2 changes: 1 addition & 1 deletion platform/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>pytorch-platform</artifactId>
<version>2.2.2-${project.version}</version>
<version>2.3.0-${project.version}</version>
</dependency>
<dependency>
<groupId>org.bytedeco</groupId>
Expand Down
6 changes: 3 additions & 3 deletions pytorch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Introduction
------------
This directory contains the JavaCPP Presets module for:

* PyTorch 2.2.2 https://pytorch.org/
* PyTorch 2.3.0 https://pytorch.org/

Please refer to the parent README.md file for more detailed information about the JavaCPP Presets.

Expand Down Expand Up @@ -48,14 +48,14 @@ We can use [Maven 3](http://maven.apache.org/) to download and install automatic
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>pytorch-platform</artifactId>
<version>2.2.2-1.5.11-SNAPSHOT</version>
<version>2.3.0-1.5.11-SNAPSHOT</version>
</dependency>

<!-- Additional dependencies required to use CUDA, cuDNN, and NCCL -->
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>pytorch-platform-gpu</artifactId>
<version>2.2.2-1.5.11-SNAPSHOT</version>
<version>2.3.0-1.5.11-SNAPSHOT</version>
</dependency>

<!-- Additional dependencies to use bundled CUDA, cuDNN, and NCCL -->
Expand Down
6 changes: 1 addition & 5 deletions pytorch/cppbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if [[ $PLATFORM == windows* ]]; then
export PYTHON_BIN_PATH=$(which python.exe)
fi

PYTORCH_VERSION=2.2.2
PYTORCH_VERSION=2.3.0

export PYTORCH_BUILD_VERSION="$PYTORCH_VERSION"
export PYTORCH_BUILD_NUMBER=1
Expand All @@ -53,10 +53,6 @@ git checkout v$PYTORCH_VERSION
git submodule update --init --recursive
git submodule foreach --recursive 'git reset --hard'

# Fix version of this submodule to allow compilation on windows.
# Probably could be removed when we upgrade to 2.3
(cd third_party/pocketfft; git checkout 9d3ab05a7fffbc71a492bc6a17be034e83e8f0fe)

CPYTHON_HOST_PATH="$INSTALL_PATH/../../../cpython/cppbuild/$PLATFORM/host/"
CPYTHON_PATH="$INSTALL_PATH/../../../cpython/cppbuild/$PLATFORM/"
OPENBLAS_PATH="$INSTALL_PATH/../../../openblas/cppbuild/$PLATFORM/"
Expand Down
8 changes: 2 additions & 6 deletions pytorch/include_list.pl
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ sub go {

chdir "cppbuild/linux-x86_64-gpu/pytorch/torch/include";

# Doesn't compile on Windows. Waiting for 2.2.1.
#go('torch/csrc/api/include/torch/torch.h', 'torch/script.h', 'torch/csrc/inductor/aoti_model_container_runner.h');
go('torch/csrc/api/include/torch/torch.h', 'torch/script.h');
go('torch/csrc/api/include/torch/torch.h', 'torch/script.h', 'torch/csrc/inductor/aoti_runner/model_container_runner_cpu.h');

print <<EOF;

Expand All @@ -64,6 +62,4 @@ sub go {
// c10/cuda/CUDAGuard.h
EOF

# Doesn't compile on Windows. Waiting for 2.2.1.
#go('ATen/cudnn/Descriptors.h', 'ATen/cudnn/Types.h', 'c10/cuda/CUDAGuard.h', '-I/opt/cuda/targets/x86_64-linux/include/', 'torch/csrc/inductor/aoti_model_container_runner_cuda.h');
go('ATen/cudnn/Descriptors.h', 'ATen/cudnn/Types.h', 'c10/cuda/CUDAGuard.h', '-I/opt/cuda/targets/x86_64-linux/include/');
go('ATen/cudnn/Descriptors.h', 'ATen/cudnn/Types.h', 'c10/cuda/CUDAGuard.h', '-I/opt/cuda/targets/x86_64-linux/include/', 'torch/csrc/inductor/aoti_runner/model_container_runner_cuda.h');
2 changes: 1 addition & 1 deletion pytorch/platform/gpu/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>org.bytedeco</groupId>
<artifactId>pytorch-platform-gpu</artifactId>
<version>2.2.2-${project.parent.version}</version>
<version>2.3.0-${project.parent.version}</version>
<name>JavaCPP Presets Platform GPU for PyTorch</name>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion pytorch/platform/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>org.bytedeco</groupId>
<artifactId>pytorch-platform</artifactId>
<version>2.2.2-${project.parent.version}</version>
<version>2.3.0-${project.parent.version}</version>
<name>JavaCPP Presets Platform for PyTorch</name>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion pytorch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>org.bytedeco</groupId>
<artifactId>pytorch</artifactId>
<version>2.2.2-${project.parent.version}</version>
<version>2.3.0-${project.parent.version}</version>
<name>JavaCPP Presets for PyTorch</name>

<dependencies>
Expand Down
4 changes: 2 additions & 2 deletions pytorch/samples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>pytorch-platform</artifactId>
<version>2.2.2-1.5.11-SNAPSHOT</version>
<version>2.3.0-1.5.11-SNAPSHOT</version>
</dependency>

<!-- Additional dependencies required to use CUDA, cuDNN, and NCCL -->
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>pytorch-platform-gpu</artifactId>
<version>2.2.2-1.5.11-SNAPSHOT</version>
<version>2.3.0-1.5.11-SNAPSHOT</version>
</dependency>

<!-- Additional dependencies to use bundled CUDA, cuDNN, and NCCL -->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Targeted by JavaCPP version 1.5.11-SNAPSHOT: DO NOT EDIT THIS FILE

package org.bytedeco.pytorch;

import org.bytedeco.pytorch.Allocator;
import org.bytedeco.pytorch.Function;
import org.bytedeco.pytorch.functions.*;
import org.bytedeco.pytorch.Module;
import org.bytedeco.javacpp.annotation.Cast;
import java.nio.*;
import org.bytedeco.javacpp.*;
import org.bytedeco.javacpp.annotation.*;

import static org.bytedeco.javacpp.presets.javacpp.*;
import static org.bytedeco.openblas.global.openblas_nolapack.*;
import static org.bytedeco.openblas.global.openblas.*;

import static org.bytedeco.pytorch.global.torch.*;


@Namespace("torch::inductor") @NoOffset @Properties(inherit = org.bytedeco.pytorch.presets.torch.class)
public class AOTIModelContainerRunner extends Pointer {
static { Loader.load(); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public AOTIModelContainerRunner(Pointer p) { super(p); }







public native @ByVal TensorVector run(
@ByRef TensorVector inputs);

public native @ByVal ExtraFilesMap getConstantNamesToOriginalFQNs();
public native @ByVal StringIntMap getConstantNamesToDtypes();
public native void update_inactive_constant_buffer(@Cast("const torch::inductor::TensorConstantMap*") @ByRef HashAliasedIValueMap const_map);
public native void update_constant_buffer(
@Cast("const torch::inductor::TensorConstantMap*") @ByRef HashAliasedIValueMap const_map,
@Cast("bool") boolean use_inactive,
@Cast("bool") boolean validate_full_updates);
public native void run_const_fold(
@Cast("bool") boolean use_inactive);
public native void swap_constant_buffer();

public native @ByVal StringVector get_call_spec();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Targeted by JavaCPP version 1.5.11-SNAPSHOT: DO NOT EDIT THIS FILE

package org.bytedeco.pytorch;

import org.bytedeco.pytorch.Allocator;
import org.bytedeco.pytorch.Function;
import org.bytedeco.pytorch.functions.*;
import org.bytedeco.pytorch.Module;
import org.bytedeco.javacpp.annotation.Cast;
import java.nio.*;
import org.bytedeco.javacpp.*;
import org.bytedeco.javacpp.annotation.*;

import static org.bytedeco.javacpp.presets.javacpp.*;
import static org.bytedeco.openblas.global.openblas_nolapack.*;
import static org.bytedeco.openblas.global.openblas.*;

import static org.bytedeco.pytorch.global.torch.*;

@Namespace("torch::inductor") @Properties(inherit = org.bytedeco.pytorch.presets.torch.class)
public class AOTIModelContainerRunnerCpu extends AOTIModelContainerRunner {
static { Loader.load(); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public AOTIModelContainerRunnerCpu(Pointer p) { super(p); }

public AOTIModelContainerRunnerCpu(
@StdString BytePointer model_so_path,
@Cast("size_t") long num_models/*=1*/) { super((Pointer)null); allocate(model_so_path, num_models); }
private native void allocate(
@StdString BytePointer model_so_path,
@Cast("size_t") long num_models/*=1*/);
public AOTIModelContainerRunnerCpu(
@StdString BytePointer model_so_path) { super((Pointer)null); allocate(model_so_path); }
private native void allocate(
@StdString BytePointer model_so_path);
public AOTIModelContainerRunnerCpu(
@StdString String model_so_path,
@Cast("size_t") long num_models/*=1*/) { super((Pointer)null); allocate(model_so_path, num_models); }
private native void allocate(
@StdString String model_so_path,
@Cast("size_t") long num_models/*=1*/);
public AOTIModelContainerRunnerCpu(
@StdString String model_so_path) { super((Pointer)null); allocate(model_so_path); }
private native void allocate(
@StdString String model_so_path);

public native @ByVal TensorVector run(@ByRef TensorVector inputs);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Targeted by JavaCPP version 1.5.11-SNAPSHOT: DO NOT EDIT THIS FILE

package org.bytedeco.pytorch;

import org.bytedeco.pytorch.Allocator;
import org.bytedeco.pytorch.Function;
import org.bytedeco.pytorch.functions.*;
import org.bytedeco.pytorch.Module;
import org.bytedeco.javacpp.annotation.Cast;
import java.nio.*;
import org.bytedeco.javacpp.*;
import org.bytedeco.javacpp.annotation.*;

import static org.bytedeco.javacpp.presets.javacpp.*;
import static org.bytedeco.openblas.global.openblas_nolapack.*;
import static org.bytedeco.openblas.global.openblas.*;

import static org.bytedeco.pytorch.global.torch.*;


// AcceleratorHooksInterface is a shared interface provided by all
// accelerators to allow generic code.
// This inferface is hook-based as it corresponds to all the functions
// that are going to be called in a generic way from the CPU code.

@Namespace("at") @Properties(inherit = org.bytedeco.pytorch.presets.torch.class)
public class AcceleratorHooksInterface extends Pointer {
static { Loader.load(); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public AcceleratorHooksInterface(Pointer p) { super(p); }

// This should never actually be implemented, but it is used to
// squelch -Werror=non-virtual-dtor

// Whether the device at device_index is fully initialized or not.
public native @Cast("bool") boolean hasPrimaryContext(@Cast("c10::DeviceIndex") byte device_index);
}
26 changes: 25 additions & 1 deletion pytorch/src/gen/java/org/bytedeco/pytorch/Allocator.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,22 @@ public class Allocator extends Pointer {
public Allocator(Pointer p) { super(p); }


public native @Name("allocate") @Cast({"", "c10::DataPtr&&"}) @StdMove DataPtr _allocate(@Cast("size_t") long n);
public native @Name("allocate") @StdMove DataPtr _allocate(@Cast("size_t") long n);

// Clones an allocation that came from this allocator.
//
// To perform the copy, this function calls `copy_data`, which
// must be implemented by derived classes.
//
// Note that this explicitly ignores any context that may have been
// attached to the input data.
//
// Requires: input data was allocated by the same allocator.
public native @StdMove DataPtr clone(@Const Pointer data, @Cast("std::size_t") long n);

// Checks if DataPtr has a simple context, not wrapped with any out of the
// ordinary contexts.
public native @Cast("bool") boolean is_simple_data_ptr(@StdMove DataPtr data_ptr);

// If this returns a non nullptr, it means that allocate()
// is guaranteed to return a unique_ptr with this deleter attached;
Expand All @@ -55,4 +70,13 @@ public class Allocator extends Pointer {
public native PointerConsumer raw_deleter();
public native Pointer raw_allocate(@Cast("size_t") long n);
public native void raw_deallocate(Pointer ptr);

// Copies data from one allocation to another.
// Pure virtual, so derived classes must define behavior.
// Derived class implementation can simply call `default_copy_data`
// to use `std::memcpy`.
//
// Requires: src and dest were allocated by this allocator
// Requires: src and dest both have length >= count
public native void copy_data(Pointer dest, @Const Pointer src, @Cast("std::size_t") long count);
}
2 changes: 2 additions & 0 deletions pytorch/src/gen/java/org/bytedeco/pytorch/AnyModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ public class AnyModule extends Pointer {
private native void allocate(@SharedPtr @Cast({"", "std::shared_ptr<torch::nn::MaxUnpool3dImpl>"}) MaxUnpool3dImpl module);
public AnyModule(FractionalMaxPool3dImpl module) { super((Pointer)null); allocate(module); }
private native void allocate(@SharedPtr @Cast({"", "std::shared_ptr<torch::nn::FractionalMaxPool3dImpl>"}) FractionalMaxPool3dImpl module);
public AnyModule(LPPool3dImpl module) { super((Pointer)null); allocate(module); }
private native void allocate(@SharedPtr @Cast({"", "std::shared_ptr<torch::nn::LPPool3dImpl>"}) LPPool3dImpl module);
public AnyModule(RNNImpl module) { super((Pointer)null); allocate(module); }
private native void allocate(@SharedPtr @Cast({"", "std::shared_ptr<torch::nn::RNNImpl>"}) RNNImpl module);
public AnyModule(LSTMImpl module) { super((Pointer)null); allocate(module); }
Expand Down
Loading
Loading