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 AI Workbench 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.

Prerequisites#

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

Start AI Workbench and Open a Project#

  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:

      1workbench@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.

    1nvwb 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.

    1  NAME  | DESCRIPTION | HOSTNAME  |  STATUS
    2--------|-------------|-----------|---------------
    3  local | My Computer | localhost | Not Running
    
  3. Run the following command to start the local location.

    1nvwb 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.

    1nvwb list projects
    
  5. Run the following command to open your project. Change <your project name> to the name of your project.

    1nvwb 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.

Customize Your Project by Installing a Package#

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.

    1nvwb 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.

Rebuild Your Project Environment#

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.

    1nvwb status
    

    You should see output similar to the following.

    1Name: test-cli-proj (/home/workbench/nvidia-workbench/test-cli-proj)
    2Description: A hello world test project
    3Environment: Full Build Required
    4Container: Running
    5Applications:
    6  jupyterlab: Stopped
    7Remote Repository: https://github.com/nkmcalli/test-cli-proj.git (Up-to-date)
    8Local 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.

    1nvwb stop --container
    
  3. Run the following command to rebuild your project.

    1nvwb 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.

    1nvwb start --container
    

Test by Using Your New Package in Code#

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.

    1nvwb 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.

    import numpy as np
    
  4. Enter the following code and then click run.

    print(np.e)
    

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

    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.

    1nvwb stop --container
    

Next Steps#