Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set device in notebook #262

Merged
merged 1 commit into from
Jan 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions sf_examples/notebooks/samplefactory_hub_example.ipynb
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"**Overview**\n",
"\n",
"This notebook explains how to run experiments using Sample-Factory, as well as upload and download models from the Hugging Face Hub. We will use OpenAI Gym's Lunar Lander environment as an example.\n",
"\n",
"Note that this notebook is for demonstration purposes only. It is not recommended to run custom Sample-Factory experiments in Jupyter Notebooks due to Python Multiprocessisng not working with functions and objects not defined in an imported module. In this example notebook, we use environment functions defined in `sf_examples`to set up the gym environment and parse custom enviornments. Including the `make_gym_env_func` directly in this notebook will result in an error when running the experiment.\n",
"Note that this notebook is for demonstration purposes only. It is not recommended to run custom Sample-Factory experiments in Jupyter Notebooks due to Python Multiprocessisng not working with functions and objects not defined in an imported module. In this example notebook, we use environment functions defined in `sf_examples` to set up the gym environment and parse custom enviornments. Including the `make_gym_env_func` directly in this notebook will result in an error when running the experiment.\n",
"\n",
"\n",
"**Step 1: Install Dependencies**\n",
"\n",
"To run this notebook, we need to install both `sample-factory` and the Lunar Lander environment using `pip`. Additional setup is required to use the Hugging Face Hub and instructions can be found at https://www.samplefactory.dev/get-started/huggingface/"
"To run this notebook, we need to install both `sample-factory` and the Lunar Lander environment using `pip`. Additional setup is required to use the Hugging Face Hub and instructions can be found at https://www.samplefactory.dev/10-huggingface/huggingface/"
]
},
{
Expand Down Expand Up @@ -85,7 +86,11 @@
"cfg.gae_lambda = 0.99\n",
"cfg.num_workers = 20\n",
"cfg.num_envs_per_worker = 6\n",
"cfg.seed = 0"
"cfg.seed = 0\n",
"\n",
"# Experiments can also be run using CPU only\n",
"# For best performance, it is recommended to turn on GPU Hardware acceleration in Colab under \"Runtime\" > \"Change Runtime Type\"\n",
"cfg.device = 'gpu' if torch.cuda.is_available() else 'cpu'"
]
},
{
Expand Down