In this tutorial, we show how to set up remote debugging with PyCharm Professional on Neuro Platform using the Neuro project template.
First, ensure that you have
neuro client installed and configured:
pip install -U neuromation neuro login
Then, initialize an empty project:
neuro project init
This command asks several questions about your project:
project_name [Name of the project]: Neuro PyCharm project_slug [neuro-pycharm]: code_directory [modules]:
Next, configure the project's environment on Neuro Platform:
Open the project created on the previous step in Pycharm Professional and add sample code to debug (in this example, we use code snipped taken from JetBrains documentation).
Then, exclude all directories that don't contain Python code (in an empty Neuro project, only
modules/ is supposed to contain code). PyCharm does not synchronize excluded directories. For that, select all directories to exclude, mouse right-click, "Mark Directory as" -> "Excluded". As a result, you will see a configured project:
Now, we are ready to start a development GPU-powered job on Neuro Platform. In the shell, run:
This command starts a
develop job on Neuro Platform, which uses
gpu-small preset. All running jobs consume your quota, so please don't forget to terminate your jobs when they are no longer needed (for that, you can run
Now, forward the job's SSH port to the localhost:
Note, if default port
2211 is not available, you can specify another port via
make port-forward-develop LOCAL_PORT=2212.
Then go back to PyCharm project, go to "File" -> "Settings", "Project" -> "Project interpreter" (you can use search by the word "interpreter"). Press on the gear sign to see project interpreter options, select "Add...". In the new window, select "SSH Interpreter", and set up the following configuration:
Host: localhost Port: 2211 Username: root
Press the Next button.
In the new window, specify paths:
Interpreter: /usr/local/bin/python Sync folders: <Project root> -> /neuro-pycharm
Note, within the job, your project root is available at the root of the filesystem:
Press the Finish button, and your configuration is ready:
Press the OK button.
Once you applied remote interpreter configuration, PyCharm starts files synchronization.
Congratulations! Your PyCharm project is now configured to work with remote Python interpreter running on Neuro job:
Note: if your project mapping was not configured and the remote interpreter attempts to execute a file with a local path on the remote environment, you might need to specify mapping again: "Run" -> "Edit Configurations..." -> "Path mappings":