User Guide (Latest)
User Guide (Latest)

Walkthrough: Customize Your Environment (CLI)

Use this documentation to learn how to customize your container environment by adding a package to your to NVIDIA AI Workbench project. For the full list, see Quickstarts and Walkthroughs.

The base container that you choose when you create your AI Workbench project might not have all the features that you need. You can customize your project by installing additional packages, customizing mounts, and defining new environment variables.

In this walkthrough, you use the command line interface (CLI) to perform the following tasks:

  1. Start AI Workbench and Open a Project

  2. Customize Your Project by Installing a Package

  3. Rebuild Your Project Environment

  4. Test by Using Your New Package in Code

Note

To create your own fully custom container, see Advanced Walkthrough: Use Your Own Container instead.

Before you complete the steps in this walkthrough, you need the following:

  1. Open a command shell by doing one of the following:

    • On macOS or Ubuntu — Open a command shell.

    • On Windows — Open the WSL app by searching for WSL in your app list. When the WSL app opens, you should see a command prompt similar to the following:

      Copy
      Copied!
                  

      workbench@computer-name:~$

      Tip

      You can also use Terminal, Command Prompt, or Windows PowerShell, and access WSL by using the command wsl -d NVIDIA-Workbench.

  2. Check the available locations (contexts) on your computer by running the following command.

    Copy
    Copied!
                

    nvwb list contexts

    If you haven’t added any remote locations yet, the only available location is the local computer. The output should look similar to the following.

    Copy
    Copied!
                

    NAME | DESCRIPTION | HOSTNAME | STATUS --------|-------------|-----------|--------------- local | My Computer | localhost | Not Running

  3. Run the following command to start the local location.

    Copy
    Copied!
                

    nvwb activate local

    AI Workbench starts and connects to your computer, and (nvwb:local) now appears at the beginning of your command prompt.

  4. Run the following command to see the names and statuses of your projects.

    Copy
    Copied!
                

    nvwb list projects

  5. Run the following command to open your project. Change <your project name> to the name of your project.

    Copy
    Copied!
                

    nvwb open <your project name>

    AI Workbench opens your project, changes to the project directory, and (nvwb:local/<your project name>) now appears at the beginning of your command prompt.

Use the following procedure to add a package to your AI Workbench project.

  1. Run the following command to open JupyterLab.

    JupyterLab opens in your default browser ready for you to start working.

    Copy
    Copied!
                

    nvwb start jupyterlab

    JupyterLab opens in your default browser ready for you to start working.

  2. In JupyterLab, in the file browser, double-click requirements.txt to open it.

    The file opens and you should see an entry for jupyterlab.

  3. Move to the first empty line in the file, type numpy, and then save the file.

  4. In JupyterLab, choose File, and then click Shut Down. Confirm shut down and close the browser tab.

Whenever you change your project environment, you must rebuild the project before you can access the changes. Use the following procedure to rebuild your environment.

  1. In your command shell, check the status of your project by running the following command.

    Copy
    Copied!
                

    nvwb status

    You should see output similar to the following.

    Copy
    Copied!
                

    Name: test-cli-proj (/home/workbench/nvidia-workbench/test-cli-proj) Description: A hello world test project Environment: Full Build Required Container: Running Applications: jupyterlab: Stopped Remote Repository: https://github.com/nkmcalli/test-cli-proj.git (Up-to-date) Local Repository: 1 Modified

    Line 8 indicates that you changed your project by editing the requirements.txt file. Line 3 indicates that the changes you made require you to rebuild your project.

  2. Run the following command to stop your container environment. If the container is already stopped you see a message that the container is not running. Continue to the next step.

    Copy
    Copied!
                

    nvwb stop --container

  3. Run the following command to rebuild your project.

    Copy
    Copied!
                

    nvwb build

    The project builds. Wait until you see Container build complete and then go to the next section to test your new package.

  4. Run the following command to start your container environment.

    Copy
    Copied!
                

    nvwb start --container

After you add the package to your project and rebuild the container environment, you can use the new package in your code.

  1. To open JupyterLab, run the following command.

    JupyterLab opens in your default browser ready for you to start working.

    Copy
    Copied!
                

    nvwb start jupyterlab

  2. In JupyterLab, navigate to the code folder. If your project already has a notebook, click to open it. Otherwise; create a new notebook by choosing Python 3 (ipykernel).

  3. In your notebook, enter the following code and then click run.

    Copy
    Copied!
                

    import numpy as np

  4. Enter the following code and then click run.

    Copy
    Copied!
                

    print(np.e)

    You should see the following output which is the value of e.

    Copy
    Copied!
                

    2.718281828459045

  5. Save your notebook.

  6. In JupyterLab, choose File, and then click Shut Down. Confirm shut down and close the browser tab.

  7. In your command shell, run the following command to stop your project environment.

    Copy
    Copied!
                

    nvwb stop --container

Previous Walkthrough: Customize Your Environment
Next Walkthrough: Add a Custom Application
© Copyright © 2024, NVIDIA Corporation. Last updated on Sep 17, 2024.