Sionna requires Python and Tensorflow.
In order to run the tutorial notebooks on your machine, you also need JupyterLab.
You can alternatively test them on Google Colab.
Although not necessary, we recommend running Sionna in a Docker container.
Sionna requires TensorFlow 2.10-2.15 and Python 3.8-3.11. We recommend Ubuntu 22.04. Earlier versions of TensorFlow may still work but are not recommended because of known, unpatched CVEs.
To run the ray tracer on CPU, LLVM is required by DrJit. Please check the installation instructions for the LLVM backend.
We refer to the TensorFlow GPU support tutorial for GPU support and the required driver setup.
The NVIDIA Container Toolkit enables users to build and run GPU-accelerated containers. The toolkit includes a container runtime library and utilities to automatically configure containers to leverage NVIDIA GPUs.
Configure the production repository:
ββββcurl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
ββββ && curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
ββββ sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
ββββ sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
Optionally, configure the repository to use experimental packages:
ββββsed -i -e '/experimental/ s/^#//g' /etc/apt/sources.list.d/nvidia-container-toolkit.list
Update the packages list from the repository:
ββββsudo apt-get update
Install the NVIDIA Container Toolkit packages:
ββββsudo apt-get install -y nvidia-container-toolkit
ββββ# Add Docker's official GPG key:
ββββsudo apt-get update
ββββsudo apt-get install ca-certificates curl
ββββsudo install -m 0755 -d /etc/apt/keyrings
ββββsudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
ββββsudo chmod a+r /etc/apt/keyrings/docker.asc
ββββ# Add the repository to Apt sources:
ββββecho \
ββββ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
ββββ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
ββββ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
ββββsudo apt-get update
ββββsudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
ββββsudo groupadd docker
ββββsudo usermod -aG docker $USER
ββββnewgrp docker
ββββdocker run hello-world
Configure the container runtime by using the nvidia-ctk
command:
ββββsudo nvidia-ctk runtime configure --runtime=docker
The nvidia-ctk
command modifies the /etc/docker/daemon.json
file on the host. The file is updated so that Docker can use the NVIDIA Container Runtime.
Restart the Docker daemon:
ββββsudo systemctl restart docker
Build the Sionna Docker image. From within the Sionna directory, run
ββββmake docker
Run the Docker image with GPU support
ββββmake run-docker gpus=all
or without GPU:
ββββmake run-docker
This will immediately launch a Docker image with Sionna installed, running JupyterLab on port 8888.
Browse through the example notebooks by connecting to http://10.0.0.162:8888/lab in your browser.
Import Sionna:
ββββimport os
ββββgpu_num = 0 # Use "" to use the CPU
ββββos.environ["CUDA_VISIBLE_DEVICES"] = f"{gpu_num}"
ββββos.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
ββββ# Import Sionna
ββββtry:
ββββ import sionna
ββββexcept ImportError as e:
ββββ # Install Sionna if package is not already installed
ββββ import os
ββββ os.system("pip install sionna")
ββββ import sionna
ββββ# IPython "magic function" for inline plots
ββββ%matplotlib inline
ββββimport matplotlib.pyplot as plt
Let us first create a BinarySource to generate a random batch of bit vectors that we can map to constellation symbols:
ββββbatch_size = 1000 # Number of symbols we want to generate
ββββnum_bits_per_symbol = 4 # 16-QAM has four bits per symbol
ββββbinary_source = sionna.utils.BinarySource()
ββββb = binary_source([batch_size, num_bits_per_symbol])
ββββb
Next, let us create a Constellation and visualize it:
ββββconstellation = sionna.mapping.Constellation("qam", num_bits_per_symbol)
ββββconstellation.show();
We now need a Mapper that maps each row of b to the constellation symbols according to the bit labeling shown above.
ββββmapper = sionna.mapping.Mapper(constellation=constellation)
ββββx = mapper(b)
ββββx[:10]
Let us now make things a bit more interesting a send our symbols over and AWGN channel:
ββββawgn = sionna.channel.AWGN()
ββββebno_db = 15 # Desired Eb/No in dB
ββββno = sionna.utils.ebnodb2no(ebno_db, num_bits_per_symbol, coderate=1)
ββββy = awgn([x, no])
ββββ# Visualize the received signal
ββββimport matplotlib.pyplot as plt
ββββimport numpy as np
ββββfig = plt.figure(figsize=(7,7))
ββββax = fig.add_subplot(111)
ββββplt.scatter(np.real(y), np.imag(y));
ββββax.set_aspect("equal", adjustable="box")
ββββplt.xlabel("Real Part")
ββββplt.ylabel("Imaginary Part")
ββββplt.grid(True, which="both", axis="both")
ββββplt.title("Received Symbols");