-
Notifications
You must be signed in to change notification settings - Fork 62
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
[ML] Upgrade PyTorch to version 1.13.1 #2430
Changes from all commits
9eee246
451c70c
5f1987f
641f53e
9df9ed9
fa82e24
a9a16b6
f1c40af
0ce3aef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -249,14 +249,53 @@ sudo ./cmake-3.23.2-Linux-x86_64.sh --skip-license --prefix=/usr/local/cmake | |
|
||
Please ensure `/usr/local/cmake/bin` is in your `PATH` environment variable. | ||
|
||
### OpenSSL | ||
|
||
Python 3.10 requires OpenSSL 1.1. No other version is acceptable. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No OpenSSL 3.0? OpenSSL 1.1.1 is LTS until 11th September 2023, hopefully we can update next time There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, next time we upgrade Python presumably a different version will be needed. But it's important to remember that we only use OpenSSL to build Python and we only use Python to build PyTorch. It's not like we use them in every build or ship them. As long as the version we've used is secure on the day we build PyTorch it's good enough. |
||
|
||
If the `openssl-devel` package for your distribution happens to be version 1.1 then you can skip this step. Otherwise, you need to build OpenSSL 1.1 from source. | ||
|
||
Download `openssl-1.1.1q.tar.gz` from <https://www.openssl.org/source/old/1.1.1/openssl-1.1.1q.tar.gz>, then build as follows: | ||
|
||
``` | ||
tar zxvf openssl-1.1.1q.tar.gz | ||
cd openssl-1.1.1q | ||
./Configure --prefix=/usr/local/gcc103 shared linux-`uname -m` | ||
make | ||
make install | ||
``` | ||
|
||
### Python | ||
|
||
PyTorch currently requires Python 3.6, 3.7 or 3.8, and version 3.7 appears to cause fewest problems in their test status matrix, so we use that. If your system does not have a requisite version of Python install it with a package manager or build the last 3.7 release from source by downloading `Python-3.7.9.tgz` from <https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tgz> then extract and build: | ||
PyTorch currently requires Python 3.7 or higher; we use version 3.10. If your system does not have a requisite version of Python install it with a package manager or build the last 3.10 release from source by downloading `Python-3.10.9.tgz` from <https://www.python.org/ftp/python/3.10.9/Python-3.10.9.tgz> then extract as follows: | ||
|
||
``` | ||
tar xzf Python-3.10.9.tgz | ||
cd Python-3.10.9 | ||
``` | ||
|
||
If the distribution you are building on uses OpenSSL 1.1 as its built in OpenSSL version then configure as follows: | ||
|
||
``` | ||
tar -xzf Python-3.7.9.tgz | ||
cd Python-3.7.9 | ||
./configure --prefix=/usr/local/gcc103 --enable-optimizations | ||
``` | ||
|
||
If you had to build OpenSSL 1.1 yourself then on x86_64 configure like this: | ||
|
||
``` | ||
sed -i -e 's~ssldir/lib~ssldir/lib64~' configure | ||
./configure --prefix=/usr/local/gcc103 --enable-optimizations --with-openssl=/usr/local/gcc103 --with-openssl-rpath=/usr/local/gcc103/lib64 | ||
``` | ||
|
||
or on aarch64 configure like this: | ||
|
||
``` | ||
./configure --prefix=/usr/local/gcc103 --enable-optimizations --with-openssl=/usr/local/gcc103 --with-openssl-rpath=/usr/local/gcc103/lib | ||
``` | ||
|
||
Finally, build as follows: | ||
|
||
``` | ||
make | ||
sudo make altinstall | ||
``` | ||
|
@@ -280,24 +319,26 @@ Then copy the shared libraries to the system directory: | |
sudo cp /opt/intel/mkl/lib/intel64/libmkl*.so /usr/local/gcc103/lib | ||
``` | ||
|
||
### PyTorch 1.11.0 | ||
### PyTorch 1.13.1 | ||
|
||
(This step requires a reasonable amount of memory. It failed on a machine with 8GB of RAM. It succeeded on a 16GB machine.) | ||
|
||
PyTorch requires that certain Python modules are installed. Install these modules with `pip` using the same Python version you will build PyTorch with. If you followed the instructions above and built Python from source use `python3.7`: | ||
PyTorch requires that certain Python modules are installed. Install these modules with `pip` using the same Python version you will build PyTorch with. If you followed the instructions above and built Python from source use `python3.10`: | ||
|
||
``` | ||
sudo /usr/local/gcc103/bin/python3.7 -m pip install install numpy ninja pyyaml setuptools cffi typing_extensions future six requests dataclasses | ||
sudo /usr/local/gcc103/bin/python3.10 -m pip install install numpy ninja pyyaml setuptools cffi typing_extensions future six requests dataclasses | ||
``` | ||
|
||
For aarch64 the `ninja` module is not available, so use: | ||
|
||
``` | ||
sudo /usr/local/gcc103/bin/python3.7 -m pip install install numpy pyyaml setuptools cffi typing_extensions future six requests dataclasses | ||
sudo /usr/local/gcc103/bin/python3.10 -m pip install install numpy pyyaml setuptools cffi typing_extensions future six requests dataclasses | ||
``` | ||
|
||
Then obtain the PyTorch code: | ||
|
||
``` | ||
git clone --depth=1 --branch=v1.11.0 git@github.com:pytorch/pytorch.git | ||
git clone --depth=1 --branch=v1.13.1 git@github.com:pytorch/pytorch.git | ||
cd pytorch | ||
git submodule sync | ||
git submodule update --init --recursive | ||
|
@@ -325,11 +366,9 @@ export USE_MKLDNN=ON | |
export USE_QNNPACK=OFF | ||
export USE_PYTORCH_QNNPACK=OFF | ||
[ $(uname -m) = x86_64 ] && export USE_XNNPACK=OFF | ||
# Breakpad is undesirable as it causes libtorch_cpu to have an executable stack | ||
export USE_BREAKPAD=OFF | ||
export PYTORCH_BUILD_VERSION=1.11.0 | ||
export PYTORCH_BUILD_VERSION=1.13.1 | ||
export PYTORCH_BUILD_NUMBER=1 | ||
/usr/local/gcc103/bin/python3.7 setup.py install | ||
/usr/local/gcc103/bin/python3.10 setup.py install | ||
``` | ||
|
||
Once built copy headers and libraries to system directories: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ | |
HOST=docker.elastic.co | ||
ACCOUNT=ml-dev | ||
REPOSITORY=ml-macosx-build | ||
VERSION=15 | ||
VERSION=16 | ||
|
||
set -e | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍