-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into hotfix/disable_deployment_confirmation
# Conflicts: # cerebrium/environments/initial-setup.mdx # examples/logo-controlnet.mdx # v4/examples/sdxl.mdx # v4/examples/transcribe-whisper.mdx
- Loading branch information
Showing
66 changed files
with
3,768 additions
and
1,117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,99 @@ | ||
--- | ||
title: "Persistent Storage" | ||
title: "Persistent Volumes" | ||
--- | ||
|
||
Cerebrium gives to access to persistent storage to store model weights, files and much more. This storage volume persists across your project, meaning that if | ||
you refer to model weights or a file created in a different deployment, you will be able to access it! | ||
Cerebrium gives you access to persistent volumes to store model weights and files. | ||
This volume persists across your project, meaning that if | ||
you refer to model weights or files created in a different app (but in the same project), you're able to access them. | ||
|
||
This allows you to load in model weights more efficiently as well as reduce the size of your deployment container images. Currently, | ||
the volume can be accessed through `/persistent-storage` in your container instance, should you wish to access it directly and store other artifacts. | ||
This allows model weights to be loaded in more efficiently, as well as reduce the size of your App container image. | ||
|
||
While you have full access to this drive, we recommend that you only store files in directories other than `/persistent-storage/cache`, as this and its subdirectories | ||
are used by Cerebrium to store your models. As a simple example, suppose you have an external SAM model that you want to use in your custom deployment. You can download it to the cache | ||
as such: | ||
### How it works | ||
|
||
```python | ||
import os | ||
import torch | ||
Every Cerebrium Project comes with a 50GB volume by default. This volume is mounted on all apps as `/persistent-storage`. | ||
|
||
file_path = "/persistent-storage/segment-anything/model.pt" | ||
# Check if the file already exists, if not download it | ||
if not os.path.exists("/persistent-storage/segment-anything/"): | ||
response = requests.get("https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth") | ||
with open(file_path, "wb") as f: | ||
f.write(response.content) | ||
### Uploading files | ||
|
||
# Load the model | ||
model = torch.jit.load(file_path) | ||
... # Continue with your initialization | ||
``` | ||
To upload files to your persistent volume, you can use the `cerebrium cp local_path dest_path` command. This command copies files from your local machine to the specified destination path in the volume. The dest_path is optional; if not provided, the files will be uploaded to the root of the persistent volume. | ||
|
||
Now, in subsequent deployments, the model will load from the cache rather than download it again. | ||
```bash | ||
Usage: cerebrium cp [OPTIONS] LOCAL_PATH REMOTE_PATH (Optional) | ||
|
||
## Increasing your Persistent Storage Size | ||
Copy contents to persistent volume. | ||
|
||
<Note>Once increased, your persistent storage size cannot be decreased.</Note> | ||
Options: | ||
-h, --help Show this message and exit. | ||
|
||
By default, your account is given 50GB of persistent storage to start with. However, if you find you need more (for example, you get an error saying `disk quote exceeded`) then you can increase your allocation using the following steps: | ||
Examples: | ||
# Copy a single file | ||
cerebrium cp src_file_name.txt # copies to /src_file_name.txt | ||
|
||
1. Check your current persistent storage allocation by running: | ||
cerebrium cp src_file_name.txt dest_file_name.txt # copies to /dest_file_name.txt | ||
|
||
# Copy a directory | ||
cerebrium cp dir_name # copies to the root directory | ||
cerebrium cp dir_name sub_folder/ # copies to sub_folder/ | ||
``` | ||
|
||
### Listing files | ||
|
||
To list the files on your persistent volume, you can use the cerebrium ls [remote_path] command. This command lists all files and directories within the specified remote_path. If no remote_path is provided, it lists the contents of the root directory of the persistent volume. | ||
|
||
```bash | ||
cerebrium storage --get-capacity | ||
Usage: cerebrium ls [OPTIONS] REMOTE_PATH (Optional) | ||
|
||
List contents of persistent volume. | ||
|
||
Options: | ||
-h, --help Show this message and exit. | ||
|
||
Examples: | ||
# List all files in the root directory | ||
cerebrium ls | ||
|
||
# List all files in a specific folder | ||
cerebrium ls sub_folder/ | ||
``` | ||
|
||
This will return your current persistent storage allocation in GB. | ||
### Deleting files | ||
|
||
2. To increase your persistent storage allocation run: | ||
To delete files or directories from your persistent volume, use the `cerebrium rm remote_path` command. This command removes the specified file or directory from the persistent volume. Be careful, as this operation is irreversible. | ||
|
||
```bash | ||
cerebrium storage --increase-in-gb <number of GB to increase by> | ||
Usage: cerebrium rm [OPTIONS] REMOTE_PATH | ||
|
||
Remove a file or directory from persistent volume. | ||
|
||
Options: | ||
-h, --help Show this message and exit. | ||
|
||
Examples: | ||
# Remove a specific file | ||
cerebrium rm /file_name.txt | ||
|
||
# Remove a directory and all its contents | ||
cerebrium rm /sub_folder/ | ||
``` | ||
|
||
### Real world example | ||
|
||
```bash | ||
wget https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth | ||
cerebrium cp sam_vit_h_4b8939.pth segment-anything/sam_vit_h_4b8939.pth | ||
``` | ||
|
||
As a simple example, suppose you have an external SAM model that you want to use in your custom deployment. You can download it to a cache directory on your persistent volume. | ||
as such: | ||
|
||
```python | ||
import os | ||
import torch | ||
|
||
file_path = "/persistent-storage/segment-anything/sam_vit_h_4b8939.pth" | ||
|
||
# Load the model | ||
model = torch.jit.load(file_path) | ||
... # Continue with your initialization | ||
``` | ||
|
||
This will return a confirmation message and your new persistent storage allocation in GB if successful. | ||
Now, in later inference requests, the model loads from the persistent volume instead of downloading again. |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.