Note: This image was specifically made for Paperspace Gradient but can be used for any other cloud service provider that supports Docker images. Make modifications if needed. Has pytorch1.12, tf29, jax0317, py39 support
Let's go through the steps to set up a deep learning Docker image with GPU support and how to quickly SSH into the server using Cloudflared if the server is not publicly accessible.
- Install Cloudflared based on your OS from the official documentation. In our example, we will use
brew install cloudflared
. - Make a Github Gist with the following content which will be used as your configuration file. Look at
config.sh
for reference. - Use the following Docker image while launching your Gradient paperSpace notebook: in the advanced settings
gs-dl-baseimage-cloudflared:latest
and in the commands section put in your Github Gist URL. - While launching your Gradient Space notebook, you should see something like this, and a sample Gist URL would look something like this
https://gist.github.com/pvbhanuteja/51b72804985318dccae8c0d8e948bf18
.
- Once your server is up and running, you can access it using the provided Cloudflare URL. The URL will be commented on your Github Gist URL automatically, or it can also be found in the Gradient Space logs. The first one is easier. Remove the
https://
part from the URL. - In your local terminal, enter the following command, replacing
<path_to_cloudflared>
andurl
with the appropriate values:
For example:
ssh -o "ProxyCommand=<path_to_clodflared> access ssh --hostname %h" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@example.com
For example:
ssh -o "ProxyCommand=cloudflared access ssh --hostname %h" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@finally-humans-faces-closed.trycloudflare.com
Now you should have access to the server.
If you want to use your own domain instead of the provided Cloudflare URL, follow these steps:
- Update your config file; look at
config.sh
for reference. - Create a new tunnel on Cloudflare by going to https://one.dash.cloudflare.com/ and navigating to Tunnels > Create a new tunnel.
- Copy the tunnel token to use it in your config.
- Once you deploy the Docker, your tunnel will be up and running. You must run the Docker image like discussed at the start before running the below steps.
- You can configure the tunnel once it is up and running by going to Tunnels > Click on your tunnel > Configure.
- Configure your tunnel and provide the domain name (you will have all your domains in the drop-down menu). Choose any subdomain of your choice, such as
workstation
. Make sure the service is pointed like the following URL:localhost:22
, and the type isssh
.
ssh -o "ProxyCommand=<path_to_clodflared> access ssh --hostname %h" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@<YOUR_SUBDOMAIN_CREATED_ON_CLOUDFLARE>
For example:
ssh -o "ProxyCommand=cloudflared access ssh --hostname %h" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@gs.bhanu.cyou
https://www.loom.com/share/a3fce56c76984f81a051cbec27822576
If you are using this on other cloud providers, you can use the following Docker image: gs-dl-baseimage-cloudflared:latest
along with gist url while running the docker image.
docker run -it pvbhanuteja/gs-dl-baseimage-cloudflared:latest <GIST_URL>
Congratulations! You have successfully set up a deep learning Docker image with GPU support and quick SSH access using Cloudflared.
I hope this was helpful. If you have any questions or comments, feel free to ask or open issue/pr on github.