Skip to content

Conversation

davidkyle
Copy link
Member

Instructions for installing the dependencies and building PyTorch on Linux

Follows the same commands used to build the docker image in #1678

Comment on lines 246 to 247
mkdir /usr/local/cmake
./cmake-3.19.3-Linux-x86_64.sh --skip-license --prefix=/usr/local/cmake
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mkdir /usr/local/cmake
./cmake-3.19.3-Linux-x86_64.sh --skip-license --prefix=/usr/local/cmake
sudo mkdir /usr/local/cmake
sudo ./cmake-3.19.3-Linux-x86_64.sh --skip-license --prefix=/usr/local/cmake

The Dockerfile runs as root, whereas the average user with a Linux laptop won't be, so best to include the sudo in these instructions.

Comment on lines 250 to 254
In your `.bashrc` file add CMake to `PATH`:

```
PATH=$PATH:/usr/local/cmake/bin
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could include this bit on line 20 so the person working through the instructions can do that all in one go.

tar -xzf Python-3.7.9.tgz
cd Python-3.7.9/
./configure --enable-optimizations
make altinstall
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this install to a directory that requires root access? If so it needs sudo, but for all the other packages we build from source we do the bulk of the build as non-root and just the install as root, i.e. this sequence occurs multiple times in this file:

make
sudo make install

Maybe there's an equivalent for Python like:

make
sudo make altinstall

Or if not then probably the whole build needs to be under sudo.

Comment on lines 295 to 298
mkdir /usr/local/gcc93/include/pytorch
cp -r torch/include/* /usr/local/gcc93/include/pytorch/
cp torch/lib/libtorch_cpu.so /usr/local/gcc93/lib
cp torch/lib/libc10.so /usr/local/gcc93/lib
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mkdir /usr/local/gcc93/include/pytorch
cp -r torch/include/* /usr/local/gcc93/include/pytorch/
cp torch/lib/libtorch_cpu.so /usr/local/gcc93/lib
cp torch/lib/libc10.so /usr/local/gcc93/lib
sudo mkdir /usr/local/gcc93/include/pytorch
sudo cp -r torch/include/* /usr/local/gcc93/include/pytorch/
sudo cp torch/lib/libtorch_cpu.so /usr/local/gcc93/lib
sudo cp torch/lib/libc10.so /usr/local/gcc93/lib

cd Python-3.7.9/
./configure --enable-optimizations
make
sudo make altinstall
Copy link
Member Author

@davidkyle davidkyle Jan 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading the makefile the altinstall target does not overwrite any current installations by updating softlinks etc. We will use altinstall rather than install and be explicit by invoking python with the full path

Copy link
Contributor

@droberts195 droberts195 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@davidkyle davidkyle merged commit 3e5d929 into elastic:feature/pytorch-inference Jan 21, 2021
@davidkyle davidkyle deleted the linux-libtorch-setup branch January 21, 2021 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants