Skip to content

Commit 54c3ca3

Browse files
committed
Merge pull request #64 from stemann/feature/torch_1.10.2
Updated for Torch v1.10.2, and NNlib >= v0.8 Replaced Torch_jll v1.4 with TorchCAPI_jll v0.2; TorchCAPI_jll v0.2 is supported by Torch_jll v1.10.2. Torch_jll uses extended platform selection (platform augmentation) which requires Julia 1.7+. Updated Julia wrapper using Julia wrapper generator (using Julia 1.11). Updated usages of functions changed in #61 (Updated C wrapper): E.g., at_grad_set_enabled. Also: * Changed tests to make CUDA optional * CI: Buildkite: Added testing on CUDA 11.3, and Julia 1.10, and 1.11 * CI: Added GitHub Actions workflow for running tests
2 parents 26147dc + 77ecce7 commit 54c3ca3

20 files changed

+5734
-2089
lines changed

.buildkite/pipeline.yaml

+29-23
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,39 @@
11
steps:
2-
- label: "GPU integration with julia v1.6"
3-
plugins:
4-
- JuliaCI/julia#v1:
5-
version: "1.6"
6-
- JuliaCI/julia-test#v1: ~
2+
- label: "Test using Julia {{matrix.julia_version}} and CUDA {{matrix.cuda_version}}"
73
agents:
84
queue: "juliagpu"
9-
cuda: "true"
5+
cuda: "*"
106
cap: sm_75
7+
matrix:
8+
setup:
9+
julia_version:
10+
- "1.10"
11+
- "1.11"
12+
cuda_version:
13+
- "10.2"
14+
- "11.3"
15+
plugins:
16+
- JuliaCI/julia#v1:
17+
version: "{{matrix.julia_version}}"
18+
- JuliaCI/julia-test#v1: ~
19+
env:
20+
CUDA_VERSION: "{{matrix.cuda_version}}"
1121
command: |
12-
TMP_PROJECT=`mktemp -d`
13-
14-
cd $$TMP_PROJECT
15-
16-
touch Project.toml
22+
CUDA_VERSION_MAJOR_MINOR=$$(echo $$CUDA_VERSION | cut -d . -f 1-2)
1723
cat <<EOT > LocalPreferences.toml
1824
[CUDA_Runtime_jll]
19-
version = "10.2"
25+
version = "$$CUDA_VERSION_MAJOR_MINOR"
2026
EOT
21-
22-
export CUDA_RUNTIME_ROOT=`julia --project --eval '
27+
julia --project --eval '
2328
using Pkg
24-
Pkg.add(name="CUDA_Runtime_jll", version="0.2")
25-
using CUDA_Runtime_jll
26-
println(CUDA_Runtime_jll.artifact_dir)
27-
'`
28-
29-
ls -1 $$CUDA_RUNTIME_ROOT/lib/libcudart*
30-
export LD_LIBRARY_PATH=$$CUDA_RUNTIME_ROOT/lib
31-
32-
cd $$BUILDKITE_BUILD_CHECKOUT_PATH
29+
CUDA_VERSION = VersionNumber(ENV["CUDA_VERSION"])
30+
if Base.thisminor(CUDA_VERSION) == v"11.3"
31+
Pkg.add(name="CUDA_Runtime_jll", version="0.7")
32+
else
33+
Pkg.add(name="CUDA_Runtime_jll")
34+
end
35+
if Base.thisminor(CUDA_VERSION) == v"10.2"
36+
Pkg.add(name="CUDNN_jll", version="8.2.4")
37+
end
38+
'
3339
timeout_in_minutes: 60

.devcontainer/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ RUN /opt/container/install_build_deps.sh $GCC_VERSION \
2424

2525
ENV JULIA_DEPOT_PATH=/opt/julia_depot
2626
ENV JULIAUP_DEPOT_PATH=/opt/juliaup
27-
RUN curl -fsSL https://install.julialang.org | sh -s -- --default-channel 1.9 --path /opt/juliaup --yes
27+
RUN curl -fsSL https://install.julialang.org | sh -s -- --default-channel 1.11 --path /opt/juliaup --yes
2828
ENV PATH=/opt/juliaup/bin:$PATH
2929

3030
ENV CUDA_VERSION=$CUDA_VERSION

.github/workflows/BuildCWrapper.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
gcc_version:
6161
- "8"
6262
julia_version:
63-
- "1.9"
63+
- "1.11"
6464
os_version:
6565
- "10"
6666
torch_version:

.github/workflows/CI.yaml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- master
6+
tags: ['*']
7+
pull_request:
8+
workflow_dispatch:
9+
concurrency:
10+
# Skip intermediate builds: always.
11+
# Cancel intermediate builds: only if it is a pull request build.
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
14+
jobs:
15+
test:
16+
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
17+
runs-on: ${{ matrix.os }}
18+
timeout-minutes: 60
19+
permissions: # needed to allow julia-actions/cache to proactively delete old caches that it has created
20+
actions: write
21+
contents: read
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
version:
26+
- '1'
27+
- lts
28+
- '1.6'
29+
os:
30+
- macOS-13 # x64 runner
31+
- macOS-latest # aarch64 runner
32+
# - ubuntu-latest
33+
arch:
34+
- aarch64
35+
- x64
36+
exclude:
37+
- os: macOS-13
38+
arch: aarch64
39+
- os: macOS-latest
40+
arch: x64
41+
- os: macOS-latest
42+
version: '1.6'
43+
# - os: ubuntu-latest
44+
# arch: aarch64
45+
# include:
46+
# - os: ubuntu-latest
47+
# arch: x86
48+
# version: '1'
49+
steps:
50+
- uses: actions/checkout@v4
51+
- uses: julia-actions/setup-julia@v2
52+
with:
53+
version: ${{ matrix.version }}
54+
arch: ${{ matrix.arch }}
55+
- uses: julia-actions/cache@v2
56+
- uses: julia-actions/julia-buildpkg@v1
57+
- uses: julia-actions/julia-runtest@v1
58+
- uses: julia-actions/julia-processcoverage@v1
59+
- uses: codecov/codecov-action@v4
60+
with:
61+
files: lcov.info
62+
token: ${{ secrets.CODECOV_TOKEN }}
63+
fail_ci_if_error: false

Project.toml

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1111
NNlib = "872c559c-99b0-510c-b3b7-b6c96a88d5cd"
1212
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
1313
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
14-
Torch_jll = "c12fb04c-f5e9-5c82-b5d6-b53f8f8d9a32"
14+
TorchCAPI_jll = "dc5d5603-8d5e-5430-85a9-2783500f9f77"
1515
ZygoteRules = "700de1a5-db45-46bc-99cf-38207098b444"
1616

1717
[compat]
1818
CEnum = "0.4, 0.5"
1919
FillArrays = "0.8, 0.9, 0.10, 0.11, 0.12, 0.13, 1"
20-
Flux = "0.11"
21-
NNlib = "0.6, 0.7.0 - 0.7.24"
20+
Flux = "0.12.9, 0.13, 0.14"
21+
NNlib = "0.8, 0.9"
2222
Requires = "1"
2323
Statistics = "1"
24-
Torch_jll = "~1.4"
25-
Zygote = "0.5"
26-
ZygoteRules = "0"
24+
TorchCAPI_jll = "0.2"
25+
Zygote = "0.5, 0.6"
26+
ZygoteRules = "0.2"
2727
julia = "1.4"
2828

2929
[extras]

README.md

+19-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
# Torch.jl
2+
23
Sensible extensions for exposing torch in Julia.
34

45
This package is aimed at providing the `Tensor` type, which offloads all computations over to [ATen](https://pytorch.org/cppdocs/), the foundational tensor library for PyTorch, written in C++.
56

6-
**Note:**
7-
* Needs a machine with a CUDA GPU (CUDA 10.1 or above)
8-
* will need lazy artifacts function without a GPU
7+
## Supported platforms
8+
9+
| **Operating System** | **Architecture** | **Acceleration Runtime** |
10+
| --- | --- | --- |
11+
| macOS | aarch64 | - |
12+
| macOS | x86_64 | - |
13+
| Linux (glibc) | aarch64 | - |
14+
| Linux (glibc) | x86_64 | CUDA 10.2 |
15+
| Linux (glibc) | x86_64 | CUDA 11.3 |
16+
17+
Windows support is pending, cf. [issue #26](https://github.com/FluxML/Torch.jl/issues/26).
18+
19+
The binary dependencies are available for Linux (glibc) on i686 (32-bit), but not all tests run succesfully.
920

1021
## Quick Start
1122

@@ -25,7 +36,7 @@ julia> using Pkg; Pkg.add("Torch");
2536
using Metalhead, Metalhead.Flux, Torch
2637
using Torch: torch
2738

28-
resnet = ResNet()
39+
resnet = ResNet(18)
2940
```
3041

3142
We can move our object over to Torch via a simple call to `torch`
@@ -64,9 +75,9 @@ end
6475
## Contributing and Issues
6576

6677
Please feel free to open issues you might encounter in the issue tracker.
67-
I would also appreciate contributions through PRs toward corrections, increased
68-
coverage, docs, etc. Testing currently runs on Linux, but that can be expanded
69-
as need arises.
78+
Contributions through PRs toward corrections, increased
79+
coverage, docs, etc. are most welcome.
7080

7181
## Acknowledgements
72-
Takes a lot of inspiration from existing such projects - ocaml-torch for generating the wrappers.
82+
83+
Takes a lot of inspiration from existing such projects, in particular [ocaml-torch](https://github.com/LaurentMazare/ocaml-torch), and [tch-rs](https://github.com/LaurentMazare/tch-rs).

0 commit comments

Comments
 (0)