You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The above example demonstrates running a python script locally and having that script transmit itself to the paperspace jobs cluster for further execution. To do this a copy of the local script is modified before transmission to the jobs cluster, in order to strip out the `import paperspace` statements and other `paperspace` library references. There are also some limitations on the types of import statements that are supported, and the dependencies that are supported in each environment (local vs. remote):
109
-
110
-
1. You need to use a bare import statement, `import paperspace`, and not use the `import paperspace as ...` form.
111
-
2. The import form `from paperspace import ...` is currently not supported.
112
-
3. Everything after the `paperspace.run()` function call is ignored when running locally (when no script name is provided). The local script execution stops after the `paperspace.run()` call.
113
-
4. Dependencies that are included before `paperspace.run()` must be available locally.
114
-
5. If you need to reference dependencies that are not available locally but are available remotely, those should be imported after the `paperspace.run()` call.
115
-
6. Dependencies that are needed remotely need to either be already installed in the container used for the job, or need to be installed using one of the techniques below in the section [Dependency Options](#dependency-options)
116
-
117
-
Because of these limitations it may not always be appropriate to run python scripts automatically from within the same script file. As an alternative you can run your python scripts unmodified using the techniques below.
118
-
119
-
120
73
Running a python script by name
121
74
===============================
122
-
You can run an python script on paperspace from the command line as follows:
75
+
You can run a Python script on a Paperspace server from the command line as follows:
123
76
124
-
gradient run myscript.py
77
+
gradient run myscript.py --name my_new_job
125
78
126
79
You can also provide additional jobs options on the command line:
127
80
128
-
gradient run myscript.py --project myproject --machineType P5000 \
81
+
gradient run myscript.py --name my_new_job --project myproject --machineType P5000 \
129
82
--container paperspace/tensorflow-python`
130
83
131
-
Alternatively you can use the `paperspace.run()` fuction in code with a script file name as the first argument:
132
-
133
-
import paperspace
84
+
Note: this functionality is deprecated and will not be available in future releases
134
85
135
-
paperspace.run('myscript.py') # runs myscript on paperspace
86
+
See the [Gradient docs](https://docs.paperspace.com/gradient/jobs/about) for the full list of jobs create options that can be specified.
136
87
137
-
In code you can provide additional paperspace jobs create options in a dict in the second argument to run():
See the Paperspace API [jobs create](https://paperspace.github.io/paperspace-node/jobs.html#.create) documentation for the full list of jobs create options that can be specified.
143
-
144
-
145
-
Using gradient run
146
-
===========================
147
-
The `gradient run` command provides a number of options to run python code and other commands remotely, as well as copy files and set up python dependencies:
The `--workspace` option allows you to specify a workspace file or directory to upload, or a git repo link to download and merge with the container. For example, to upload the current directory along with a script file run:
212
140
213
-
gradient run myscript.py --workspace .
141
+
gradient run myscript.py --name my_new_job --workspace workspace-dir
142
+
143
+
Note: `--workspace` defaults to `.`
214
144
215
145
See the Paperspae API [jobs create](https://paperspace.github.io/paperspace-node/jobs.html#.create) documentation for more details on the `--workspace` option and related options.
216
146
217
147
The `--ignoreFiles "<file-or-dir>,..."` option can be used specify a simple comma separated list of files and directories to ignore for the workspace upload:
218
148
219
-
gradient run myscript.py --workspace . --ignoreFiles "hello.py,paperspace"
149
+
gradient run myscript.py --name my_new_job --workspace . --ignoreFiles "hello.py,paperspace"
220
150
221
151
The following files and directories are ignored by default: `.git`, `.gitignore`, `__pycache__`.
222
152
223
-
Other `jobs create options` can be specified, such as `--machineType <machine type>`, `--container <container image reference>`, and `--project <project name>`.
224
-
225
-
Here are some of the other jobs create options available:
226
-
227
-
- `--project "<project name>"` (defaults to 'paperspace-python')
228
-
- `--machineType [C2|C7|GPU+|P4000|P5000|P6000|V100|G1|G6|G12|K80|GV100|GV100x8]` (defaults to P5000)
229
-
- `--container <docker image link or paperspace container name>` (defaults to `docker.io/paperspace/tensorflow-python`)
230
-
- `--name "<job name>"` (defaults to 'job for project <project name>')
- `--registryUsername "<username>"` (for access to a private docker registry)
233
-
- `--registryPassword "<secretpw>"` (for access to a private docker registry)
234
-
- `--workspaceUsername "<username>"` (for access to a private git repo)
235
-
- `--workspacePassword "<secretpw>"` (for access to a private git repo)
153
+
Other `jobs create` options can be specified, such as `--machineType <machine-type>`, `--container <container-image-reference>`, and `--project <project-name>`.
236
154
237
155
See the Paperspae API [jobs create](https://paperspace.github.io/paperspace-node/jobs.html#.create) documentation for a complete description of these options.
238
156
239
-
Dependency Options
240
-
==================
241
-
When running python scripts on paperspace you may need to provide additional dependencies to your scripts or specify the python version.
242
-
The `gradient run` command has several options to support this: `--python`, `--init`, `--pipenv`, and `--req`. In addition you can use the `--workspace` option above to upload file dependencies.
243
-
244
-
The `--python 2|3` option allows you specify whether to use `python2` or `python3` when running the script on paperspace.
245
-
If ommitted, the script will be run with the same major version as is being used to run `gradient` locally.
246
-
247
-
The `--init [<init.sh>]` option is used to specify a script to be run on the remote machine, inside the container, before the python script is run.
248
-
If the init script name is ommitted, it is assumed to be the script named `init.sh` in the current directory. The script is run using
249
-
`source init.sh` in the container bash shell. You can use this option to provide a list of commands to run to set up the dependencies for the script, such as running a list of `pip install` commands. However, if you are using `pipenv` or a `requirements.txt` file we recommend you use one of the options below. Multiple dependency setup options can be combinded however.
250
-
251
-
The `--pipenv` option is used to upload and run the `Pipfile` and `Pipfile.lock` files in the current directory, if found. These files
252
-
are used on the paperspace machine to initialize the python environment using the `pipenv` tool, by running `pipenv install` within the container. Note: `pipenv` must already be installed in the container for this option to work. The default container used by gradient already has the `pipenv` package installed.
253
-
254
-
The `--req [<requirements.txt>]` option is used specify that a `requirements.txt` file should be used to install the required python dependencies using `pip`.
255
-
By default this option looks for a file named `requirements.txt` in the current directory, but you can override this by specifying a different file name. Note: `pip` must already be installed in the container for this option to work. The default container used by gradient already has the `pip` package installed.
256
-
257
-
The `--dryrun` option allows you to see the resultant script that will be run on the paperspace job runner without actually running it.
258
-
259
-
All of the above options can be combined in any combination, however, the order of operations is fixed to the following:
260
-
261
-
1. `source <init.sh>` is run if `--init <init.sh>` is specified
262
-
2. `pipenv [--two|--three] install` is run if `--pipenv` is specified
263
-
3. `pip[2|3] install -r requirements.txt` is run if `--req <requirements.txt>` is specified
264
-
4. `python[2|3] myscript.py` is run
265
-
266
-
As mentioned above, you can use the `--dryrun` option to see the resultant commands that will be run on the paperspace jobs cluster node for a given set of options, without actually running the commands.
267
-
268
157
269
158
Default Container
270
159
=================
@@ -278,20 +167,13 @@ Other examples
278
167
See the scripts in the `tests` folder for other examples.
279
168
280
169
281
-
Other Authentication options
170
+
Authentication options
282
171
============================
283
-
1. Specify your apiKey explicitly on the paperspace.run() function or any of the paperspace.jobs methods, e.g.:
3. Set the PAPERSPACE_API_KEY environment variable:
176
+
2. Set the PAPERSPACE_API_KEY environment variable:
295
177
296
178
(on linux/mac:) `export PAPERSPACE_API_KEY=1qks1hKsU7e1k...`
297
179
@@ -300,17 +182,10 @@ Other Authentication options
300
182
Note: the above methods take precedence over use of the cached api key in
301
183
`~/.paperspace/config.json`
302
184
303
-
4. Set the key in the `~/.paperspace/config.json` file from the command line by running:
304
-
305
-
`gradient apikey 1qks1hKsU7e1k...`
306
-
185
+
3. Set the key in the `~/.paperspace/config.json` file from the command line by running:
307
186
308
-
Using SAML, AD or GitHub credentials
309
-
====================================
310
-
Currently only email login is supported in the CLI - if you're using AD, SAML or GitHub to login to Paperspace, you will need an API key to log in with the CLI.
187
+
`gradient apiKey 1qks1hKsU7e1k...`
311
188
312
-
You can create an API key from within your Paperspace console under the [API](https://www.paperspace.com/console/account/api) section. Login to your [Paperspace console](https://www.paperspace.com/console), scroll to the API section in the left navigation bar, and click [CREATE AN API KEY](https://www.paperspace.com/console/account/api). Follow the instructions there.
313
-
You will need to pick and API token name for your API key, and also provide a description. You can copy the API key value associated with the API token name only at the time of initial creation. If you need to access your API key in the future, you can instead access it by API token name using the 'gradient login' command.
0 commit comments