Shanghai Institute of Semiconductor Innovation (SISI) logo

AI Computing Systems (EE219)

Shanghai Institute of Semiconductor Innovation (SISI)

Lab 0

Introduction

Welcome to EE219: AI Computing Systems! In this first lab assignment (SISI, EE219), we will guide you through setting up your local development environment and introduce you to basic PyTorch operations. Here’s how you can get started:

Local PC Account

For Lab 0 and Lab 1, use the PC issued by SISI. It has an Intel Core Ultra 7 265K CPU and no discrete graphics card. Both labs run locally on the CPU; MetaX computing resources are not provided for these assignments.

Log in to your PC with your assigned account. Remember your password and do not share your account or password with others. Familiarize yourself with the operating system and terminal on your PC.

Using VS Code for Local Development

We use Visual Studio Code (VS Code) here as an example. You can open and run the notebooks directly on your SISI PC; a remote server or SSH connection is not needed.

Install VS Code

Download and install Visual Studio Code from this link: Download Visual Studio Code.

Open the Local Lab Folder

Save the provided lab files in a writable folder on your PC. In VS Code, select File → Open Folder and choose that folder.

Install Python and Jupyter Extension

Open VS Code and navigate to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window. Search for “Python” and “Jupyter”, then install and enable both extensions locally.

PyTorch Tutorial

Introduction to Miniconda

Miniconda is a minimal installer for Conda, an open-source package management system and environment management system that helps to simplify the installation and management of software packages and environments. Miniconda includes only Conda and its dependencies, making it a lightweight alternative to the full Anaconda distribution. This allows users to create isolated environments with specific package versions, ensuring compatibility and reproducibility across different projects.

Use a local Conda environment with CPU-only PyTorch on your SISI PC. If Conda is not already installed, install Miniconda for your operating system from the Miniconda installation guide. Open a Conda-enabled terminal (Anaconda Prompt on Windows).

Environment management

When you see (base) in the command line prompt, it indicates that you are in the base Conda environment. This is the default environment created by Conda when it is first installed. Being in the (base) environment means that any packages installed or commands executed will be within this default environment.

Create a Python environment named ee219-cpu once, then activate it whenever you work on the labs:

  1. Activate the Course Environment.
    $ conda create -n ee219-cpu python=3.11 -y
    $ conda activate ee219-cpu

    After activation, the command-line prompt should show (ee219-cpu).

  2. Deactivate the Course Environment. When you’re done working in the course environment and wish to return to the base environment, you can deactivate it by running:
    $ conda deactivate 

    After deactivating, you will see (base) again, indicating that you are back in the base Conda environment.

Package management

pip is the package installer for Python, allowing you to install and manage additional libraries and dependencies that are not part of the standard library. It is an essential tool for Python developers to extend the functionality of Python by downloading and installing third-party packages from the Python Package Index (PyPI).

After activating ee219-cpu, install CPU-only PyTorch and torchvision, followed by the notebook dependencies. Use the CPU package source described in the PyTorch installation guide.

$ python -m pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
$ python -m pip install jupyter ipykernel matplotlib numpy tqdm pandas pillow imageio -i https://pypi.tuna.tsinghua.edu.cn/simple/  

Note that “-i" is followed by the Tsinghua University mirror source, which allows us to download and install packages more quickly and steadily.

Feel free to contact TAs if you have any questions or encounter any issues.

Instructions

Download the Lab 0 assignment PDF (SISI).

The goal of this lab is to get you familiarized with basic PyTorch operations. The following are the basic steps.

  1. Download the provided IPython notebook.
  2. Save the notebook in your local Lab0 folder and open that folder in VS Code.
  3. Activate ee219-cpu and install the dependencies as described above. The notebook's device selection falls back to cpu on this PC. With CPU-only PyTorch, torch.cuda.is_available() returns False; this is expected.
  4. Click on the Jupyter Notebook file to launch it in VS Code. Note that you may need to install the necessary Jupyter extension beforehand. If needed, refer to “Install Python and Jupyter Extension” above.
  5. Select python environment for this notebook. Look at the top right corner of the page. You will see a button that allows you to select the kernel. Click on the dropdown menu in the top right corner. You will see a list of available kernels and select the kernel corresponding to the ee219-cpu environment.
  6. The notebook uses ./data as the Fashion-MNIST data root. Keep the notebook's working directory set to your local Lab0/ folder so the dataset is stored in a writable location.
  7. Follow the steps in the notebook. Make sure to understand the basic functionalities of PyTorch as these will be fundamental for future labs.

Task 1

(2 points) Save the visualized inference results of the trained model on 40 test images.

Task 2

(2 points) Determine the type of your CPU, the number of CPU cores, the capacity of DRAM, the operating system version, and the PyTorch version within ee219-cpu on your SISI PC. Record the available graphics device information and state that this PC has no discrete GPU; discrete GPU memory is not applicable. Save the screenshots of your query command and its results from the command line.

Use your operating system's hardware query commands. For example, on Linux use lscpu, free -h, cat /etc/os-release, and lspci; on Windows, use PowerShell commands such as Get-CimInstance Win32_Processor, Get-CimInstance Win32_ComputerSystem, Get-CimInstance Win32_OperatingSystem, and Get-CimInstance Win32_VideoController. Query PyTorch with python -c "import torch; print(torch.__version__)".

Submission

Compile the content of the above two tasks into a PDF file, name the file with your student ID and name, and upload it via Gradescope.

If you use AI, please follow the requirements introduced in class and submit a separate AI report on Gradescope.