JarvisLabs Client
Is a Python API for Interacting with Jarvislabs.ai for creating GPU/CPU-powered instances.
Steps to get started
- Install JLclient
- Generate API token
- Authentication
- Create an Instance object which will let you -
- Launch GPU/CPU powered instance
- Pause the instance
- Resume
- Destroy
- Use the User class to
- get instances that are in running and paused state.
- Use FileSystem class to manage FileSystem lifecycle.
- Attach a FileSystem to an instance during creation.
- Attach a FileSystem to an instance during resume.
Installation
pip install git+https://github.com/jarvislabsai/jlclient.git
Generate API token
you can Generate API token from Jarvislabs.ai.
Imports and configure
from jlclient import jarvisclient
from jlclient.jarvisclient import *
jarvisclient.token = '**************************duWRbO68IiMTkQKWi48'
Managing GPU/CPU powered instances on Jarvislabs.ai
Create Instance
Attributes
Parameter | Type | Description/Values | Default Value |
---|---|---|---|
instance_type | str | Choose between GPU or CPU. | GPU |
num_gpus / num_cpus | int | According to the instance_type, choose the number of GPUs or CPUs. | 1 |
gpu_type | str | Choose from A100, A5000, A6000, RTX6000Ada, RTX5000. | RTX5000 |
template | str | Use User.get_templates() in our JLclient to get all templates. | pytorch |
script_id | str | If you have a script you can pass it. | None |
is_reserved | bool | True refers to an on-demand instance. False refers to a spot instance. | True |
duration | str | Choose hour, week, and month. The pricing changes based on the duration.. | hour |
http_ports | str | As per your requirement, you can specify the ports. | None |
storage | int | Choose between 20GB to 2TB. | 20 |
# Launch CPU Instance
instance: Instance = Instance.create('CPU',
num_cpus=1,
storage=25,
name='cpu instance')
# Launch GPU Instance
instance: Instance = Instance.create('GPU',
gpu_type='RTX6000Ada',
num_gpus=1,
storage=50,
name='gpu instance')
This should return the Instance object.
you can access the below attributes using the Instance object.
- gpu_type
- num_gpus
- num_cpus
- storage
- name
- machine_id
- script_id
- is_reserved
- duration
- script_args
- http_ports
- template
- url
- endpoints
- ssh_str
- status
Pause the instance
instance.pause()
You can call pause()
on any Instance
object.
Resume the instance
#Resuming with existing configuration
instance.resume()
#Modifying the parameters like scaling GPUs, switching GPU type, expanding storage, etc.
instance.resume(num_gpus=1,
gpu_type='RTX5000',
storage=100)
#Switching from GPU to CPU Instance
instance.resume(num_cpus=1,
storage=25)
#Switching from CPU to GPU Instance
instance.resume(gpu_type='RTX6000Ada',
num_gpus=1,
storage=25)
You can modify an existing instance by changing the below resume
parameters.
-
num_gpus
-
gpu_type
-
storage
or just call resume
without any parameters to start the instance with the same configuration.
Destroy the instance
instance.destroy()
Pausing inside a Jarvislabs instance
You can use the below function to pause an instance
import os
from jlclient import jarvisclient
from jlclient.jarvisclient import *
jarvisclient.token = "*****"
def pause():
machine_id = os.getenv('MACHINE_ID')
instance = User.get_instance(machine_id)
instance.pause()
User management
The User
class comes with the below key functionalities.
-
User.get_templates()
: Returns the list of templates available. -
User.get_instances()
: Returns a list ofInstance
objects representing all the instances in your account. -
User.get_balance()
: Return the balance of the user.
FileSystem
You can use the FileSystem class to create, delete and list all the filesystems in your account.
fs = FileSystem()
fs.list() # List all the filesystems in your account.
fs.create(fs_name='test', storage=500) # Create a new filesystem with the given name and size, returns fs_id that can be used to attach fs to an instance.
fs.delete(fs_id=333) # Delete the filesystem with the given name.
Attach FileSystem to an instance during creation
instance: Instance = Instance.create('GPU',
gpu_type='RTX6000Ada',
num_gpus=1,
storage=50,
name='gpu instance',
fs_id='332'
)
Attach FileSystem to an instance during resume
instance.resume(fs_id='333')
You can get the fs_id
by calling fs.list()
Issues/Feature request
Do you like to see any new features, we are all ears. You can drop us an email at hello@jarvislabs.ai or chat with us for requesting any new features or reporting issues.
License
This project is licensed under the terms of the MIT license.