Skip to content

Instantly share code, notes, and snippets.

@beratkurar
Last active September 16, 2018 07:54
Show Gist options
  • Save beratkurar/4f7869e14928a8f0288d0d06770e21c8 to your computer and use it in GitHub Desktop.
Save beratkurar/4f7869e14928a8f0288d0d06770e21c8 to your computer and use it in GitHub Desktop.
Configure Ben-Gurion University deep learning server Docker container as Pycharm Pro remote interpreter.

Followings are the steps to configure Python interpreter in a docker container in the deep learning server csdlsrv1 as the remote interpreter of a Pycharm Pro project.

  1. In csdlsrv1:
$ cd /DATA/username/
$ mkdir exp
$ cd exp
$ nano Dockerfile

FROM dl-image

RUN apt-get update && apt-get install -y openssh-server
RUN mkdir /var/run/sshd
RUN echo 'root:1234567' | chpasswd
RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config

# SSH login fix. Otherwise user is kicked off after login
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd

ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile

EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]

ctrl+o
ctrl+x

$ nvidia-docker build -t expimage .
$ nvidia-docker run -d -P --name expcontainer expimage
$ nvidia-docker port test_sshd 22
0.0.0.0:32779

$ ssh root@localhost -p 32779
# The password is 1234567
root@f38c87f2a42d:/#
$ cd ..
$ chmod 777 root
  1. In local:
$ rm ~/.ssh/known_hosts
$ pkill ssh
$ ssh -f lvs.cs.bgu.ac.il -L 1234:csdlsrv1:32779 -N
$ ssh root@localhost -p 1234
$ scp -P 1234 myfile.py root@localhost:
root@0f224ae7bead:~# 
  1. In Pycharm Pro (Free for students):
Create new project
Pure Python
Preferences
Project interpreter
Add interpreter
SSH interpreter
Host: localhost
Port: 1234
User: root
Password: 1234567

Useful links

Dockerize an SSH service

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment