Open5
Python3.13 No-GIL の自力ビルドとインストールの試行 + onnxruntime v1.19.2
wget wget https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz
tar -xf Python-3.13.0.tgz
cd Python-3.13.0
./configure --disable-gil --enable-optimizations
make -j$(nproc)
make altinstall
Dockerfile
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
ENV USERNAME=user
ENV VIRTUAL_ENV="/usr/share/python3/app"
ENV PATH=${VIRTUAL_ENV}/bin:${PATH}
ARG WKDIR=/home/${USERNAME}/workdir
SHELL ["/bin/bash", "-c"]
RUN apt update \
&& apt install -y software-properties-common \
&& add-apt-repository ppa:deadsnakes/ppa \
&& apt-get purge -y software-properties-common \
&& apt update \
&& apt install -y \
sudo \
curl \
nano \
build-essential \
git \
wget \
libgl1-mesa-dev \
make \
libssl-dev \
zlib1g-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
llvm \
libncurses5-dev \
libncursesw5-dev \
xz-utils \
tk-dev \
libffi-dev \
liblzma-dev \
libgdbm-dev \
libdb-dev
RUN wget https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz \
&& tar -xf Python-3.13.0.tgz \
&& cd Python-3.13.0 \
&& ./configure --disable-gil --enable-optimizations \
&& make -j$(nproc) \
&& make altinstall
RUN echo "root:root" | chpasswd \
&& adduser --disabled-password --gecos "" "${USERNAME}" \
&& echo "${USERNAME}:${USERNAME}" | chpasswd \
&& echo "%${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/${USERNAME} \
&& chmod 0440 /etc/sudoers.d/${USERNAME} \
&& mkdir -p ${WKDIR} \
&& chown ${USERNAME}:${USERNAME} ${WKDIR} \
&& mkdir -p ${VIRTUAL_ENV} \
&& chown -R ${USERNAME}:${USERNAME} ${VIRTUAL_ENV}
USER ${USERNAME}
WORKDIR ${WKDIR}
RUN echo 'export VIRTUAL_ENV=${VIRTUAL_ENV}' >> ${HOME}/.bashrc \
&& echo 'export PATH="${VIRTUAL_ENV}/bin:${PATH}"' >> ${HOME}/.bashrc \
&& echo 'sudo chmod 777 /dev/video*' >> ${HOME}/.bashrc \
&& python3.13t -m venv ${VIRTUAL_ENV} \
&& python3.13t -m pip install -U \
setuptools==75.3.0 \
wheel==0.44.0 \
websockets==13.1 \
pillow==11.0.0 \
imageio[ffmpeg]==2.36.0 \
click==8.1.7
docker build -t test --no-cache .
docker run --rm -it \
-v `pwd`:/home/user/workdir \
--device /dev/video0:/dev/video0:mwr \
--net host \
-e XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix/:/tmp/.X11-unix:rw \
test
python -V
Python 3.13.0
which python
/usr/share/python3/app/bin/python
ls -lh /usr/share/python3/app/bin/python
lrwxrwxrwx 1 user user 11 Oct 31 15:27 /usr/share/python3/app/bin/python -> python3.13t
pip install cmake==3.27.5 ninja==1.11.1.1 packaging==24.1
### build gtest
# ビルドするバージョンはココから適当に選択する
# ホストPCがUbuntu22.04だったのでとりあえず1.11.0に合わせた
# https://packages.ubuntu.com/search?keywords=googletest
wget https://github.com/google/googletest/archive/release-1.11.0.tar.gz \
&& tar xzf release-1.11.0.tar.gz \
&& cd googletest-release-1.11.0
mkdir build \
&& cd build \
&& cmake .. -DCMAKE_CXX_FLAGS="-fPIC" \
&& make \
&& sudo make install \
&& cd ../..
git clone -b v1.19.2 https://github.com/microsoft/onnxruntime.git \
&& cd onnxruntime
./build.sh \
--config Release \
--cmake_generator Ninja \
--enable_pybind \
--build_wheel \
--parallel $(nproc) \
--compile_no_warning_as_error \
--skip_tests
find . -name "*.whl"
./build/Linux/Release/dist/onnxruntime-1.19.2-cp313-cp313t-linux_x86_64.whl
pip install ./build/Linux/Release/dist/onnxruntime-1.19.2-cp313-cp313t-linux_x86_64.whl