Full PyCharm-GUI-IDE window on ubuntu host desktop for machine learning projects with NVIDIA-GPU
80
Change directory to your project folder and run the following command on the command line:
nvidia-docker run --interactive --tty --env DISPLAY=$DISPLAY --volume /tmp/.X11-unix/:/tmp/.X11-unix/ --volume $PWD:/home/developer/project/ --rm drstoop/pycharm_gui_nvidia:tf-gpu-1.12.0-pytorch-1.0.0-py-3.5.2-cuda-10.0-cudnn-7.4.1
This docker image embeds the PyCharm GUI seemlessly in your host machine desktop. It is meant mainly for R&D of machine learning projects where you do not want to miss the full comforts of the PyCharm-IDE. For production you would not use this image with a full IDE.
/home/developer/ as PyCharm project folder because it will mess up your PyCharm settings/configs stored in the same folder in /home/developer/.PyCharmCE2018.3/*.PyCharmCE2018.3/* folder into your docker build folder.developer) has the same user- & group-id as the user (you!) on the host machine. If this is not the case rebuild the docker image with information below or change the user-/group-id of the docker-user developeraddording to the host machine user, commit and relaunch. Second should hopefully be enough.Ubuntu 16.04.5, Python 3.5.2
Following files were used for building image:
This script helps running the container optimally as alternative to the quick launch command (see above):
Launch pycharm_gui_nvidia image with default or customized tag running command:
$ . launch_image.sh # for default image
$ . launch_image.sh <customized tag> # for customized image tag
NOTE: Multiple RUN commands were required to ensure sequential installation prerequisits.
FROM nvcr.io/nvidia/tensorflow:18.11-py3
# BUILD COMMAND
# docker build --tag drstoop/pycharm_gui_nvidia:tf-18.11-py3 --build-arg PYCHARM_EDITION=<pycharm-<community/professional>-<version> --build-arg 'PyCharm'<CE/PF><main-version, e.g. 2018.3>'/config/' .
# RUN COMMAND
# docker run -interactive --tty --env DISPLAY=$DISPLAY --volume /tmp/.X11-unix/:/tmp/.X11-unix/ --volume ${pwd}:/home/developer/project/ --rm drstoop/pycharm_gui_nvidia:tf-gpu-1.12.0-pytorch-1.0.0-py-3.5.2-cuda-10.0-cudnn-7.4.1
ARG PYCHARM_EDITION
ARG PYCHARM_CONFIG
ARG PYCHARM_SETTINGS=settings.zip
ARG REQUIREMENTS_FILE=pip_requirements.txt
ARG REQUIREMENTS_PATH=/tmp/$REQUIREMENTS_FILE
ARG UID=${id --user}
ARG GID=${id --group}
ADD $PYCHARM_EDITION'.tar.gz' /opt/
# Replace 1000 with your user / group id
RUN apt update \
&& \
apt install -y sudo \
libxext6 \
libxrender1 \
libxtst6 \
libxi6 \
libfreetype6 \
python3-tk \
&& \
ln -s /opt/$PYCHARM_EDITION/bin/pycharm.sh /bin/pycharm \
&& \
mkdir -p /home/developer \
&& \
mkdir -p /etc/sudoers.d \
&& \
echo "developer:x:$UID:$GID:Developer,,,:/home/developer:/bin/bash" >> /etc/passwd \
&& \
echo "developer:x:$UID:" >> /etc/group \
&& \
echo "developer ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/developer \
&& \
chmod 0440 /etc/sudoers.d/developer \
&& \
chown $UID:$GID -R /home/developer
COPY $REQUIREMENTS_FILE $REQUIREMENTS_PATH
RUN pip --no-cache-dir install --requirement ${REQUIREMENTS_PATH} \
&& \
rm ${REQUIREMENTS_PATH}
USER developer
COPY --chown=developer:developer /.PyCharmCE2018.3/ /home/developer/.PyCharmCE2018.3/
ENV HOME /home/developer
# ENTRYPOINT pycharm
#! /bin/bash
# ./build_image.sh <PYCHARM_EDITION> <IMAGE_REPOSITORY_TAG> <CUSTOMIZED_BUILD_OPTION>
PYCHARM_EDITION=$1
IMAGE_REPOSITORY_TAG=$2
CUSTOMIZED_BUILD_OPTIONS=${@:3}
DEFAULT_PYCHARM_EDITION='pycharm-community-2018.3.1'
DEFAULT_PYCHARM_CONFIG='.PyCharmCE2018.3/config/'
DEFAULT_REPOSITORY_TAG='drstoop/pycharm_gui_nvidia:tf-18.11-py3'
echo -e '\nUser defined build-args as:' \
'\nPYCHARM_EDITION='$PYCHARM_EDITION \
'\nIMAGE_REPOSITORY_TAG='$IMAGE_REPOSITORY_TAG
if [ -z $1 ]; then
echo -e '\nPYCHARM EDITION was not defined by user.' \
'\nSetting PYCHARM_EDITION AND PYCHARM_CONFIG to default value...'
PYCHARM_EDITION=$DEFAULT_PYCHARM_EDITION
PYCHARM_CONFIG=$DEFAULT_PYCHARM_CONFIG
echo -e 'PYCHARM_EDITION='$PYCHARM_EDITION \
'\nPYCHARM_CONFIG='$PYCHARM_CONFIG
elif [-n $1 ]; then
PYCHARM_EDITION=$1
echo -e '\nPYCHARM_EDITION is user defined.'
'\nSetting PYCHARM_CONFIG to default value...'
PYCHARM_CONFIG='.PyCharmCE'${PYCHARM_EDITION: -8: -2}'/config/'
echo -e 'PYCHARM_EDITION='$PYCHARM_EDITION
'\nPYCHARM_CONFIG='$PYCHARM_CONFIG
fi
if [ -z $2 ]; then
echo -e 'IMAGE_REPOSITORY_TAG was not defined by user.' \
'\nSetting IMAGE_REPOSITORY_TAG to default value...'
IMAGE_REPOSITORY_TAG=$DEFAULT_REPOSITORY_TAG
echo 'IMAGE_REPOSITORY_TAG='$IMAGE_REPOSITORY_TAG
fi
echo -e '\nFinal build-args:' \
'\nPYCHARM_EDITION='$PYCHARM_EDITION \
'\nPYCHARM_CONFIG='$PYCHARM_CONFIG \
'\nIMAGE_REPOSITORY_TAG='$IMAGE_REPOSITORY_TAG \
echo -e '\nbuilding docker image...' \
'\n$ docker build --build-arg PYCHARM_EDITION='$PYCHARM_EDITION \
'\n --build-arg PYCHARM_CONFIG='$PYCHARM_CONFIG \
'\n '$CUSTOMIZED_BUILD_OPTIONS \
'\n --tag='$IMAGE_REPOSITORY_TAG' .\n\n'
# echo -e '\nUnzipping settings.zip to config/ ...'
# unzip -o settings.zip -d config/
docker build --build-arg PYCHARM_EDITION=$PYCHARM_EDITION \
--build-arg PYCHARM_CONFIG=$PYCHARM_CONFIG \
$CUSTOMIZED_BUILD_OPTIONS \
--tag $IMAGE_REPOSITORY_TAG .
# echo -e '\cleaning docker image folder...'
# rm -rv config/
echo -e '\nend'
# add additional pipy-packages here
PyCharm installation file of desired version to be installed
Complete PyCharm settings & config folder of customized PyCharm, e.g. which you always use
Helper file for launching (optional)
#!/bin/bash
# Launch pycharm_gui_nvidia image with default or customized tag running command:
# $ . launch_image.sh # for default image
# $ . launch_image.sh <customized tag> # for customized image tag
# Help function
if [ $1 == '--help' ] || [ $1 == '-h' ]; then
echo -e 'Launch pycharm_gui_nvidia image with default or customized tag running command:' \
'\n$ . launch_image.sh # for default image' \
'\n$ . launch_image.sh <customized tag> # for customized image tag'
return
fi
IMAGE_REPOSITORY_TAG=$1
DEFAULT_REPOSITORY='drstoop/pycharm_gui_nvidia'
DEFAULT_TAG='tf-18.11-py3'
if [ -z $1 ]; then
IMAGE_REPOSITORY_TAG=$DEFAULT_REPOSITORY':'$DEFAULT_TAG
echo -e 'Launching default image "'$IMAGE_REPOSITORY_TAG'"...'
else
IMAGE_REPOSITORY_TAG=$DEFAULT_REPOSITORY':'$1
echo -e 'Launching customized image "'$IMAGE_REPOSITORY_TAG'"...'
fi
echo -e '$ nvidia-docker run --interactive --tty --env DISPLAY=$DISPLAY --volume /tmp/.X11-unix/:/tmp/.X11-unix/ --volume $PWD:/home/developer/project/ --rm '$IMAGE_REPOSITORY_TAG
nvidia-docker run --interactive --tty --env DISPLAY=$DISPLAY --volume /tmp/.X11-unix/:/tmp/.X11-unix/ --volume $PWD:/home/developer/project/ --rm $IMAGE_REPOSITORY_TAG
Content type
Image
Digest
Size
2.9 GB
Last updated
almost 8 years ago
docker pull drstoop/pycharm_gui_nvidia:tf-gpu-1.12.0-pytorch-1.0.0-py-3.5.2-cuda-10.0-cudnn-7.4.1