安装开发工具包

localhost:~# apk add build-base git
localhost:~# apk add zlib-dev
localhost:~# gcc --version
gcc (Alpine 10.3.1_git20210424) 10.3.1 20210424
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

编译安装 Python 3.6

localhost:~# wget https://www.python.org/ftp/python/3.6.15/Python-3.6.15.tgz
localhost:~# tar -xvf Python-3.6.15.tgz
localhost:~# cd Python-3.6.15/
localhost:~/Python-3.6.15# ./configure --enable-optimizations --with-ensurepip=install
localhost:~/Python-3.6.15# make -j2
localhost:~/Python-3.6.15# make altinstall
localhost:~/Python-3.6.15# cd /usr/local/bin/
localhost:/usr/local/bin# ln -s python3.6 python
localhost:/usr/local/bin# ln -s pip3.6 pip3

localhost:~# python --version
Python 3.6.15

安装 Pytorch

Alpine linux 的C库是 musl libc 而非 glibc