Jupyter Tips and Tricks

Run Jupyter Notebooks with GPU Support

CoCalc allows you to easily use basic and advanced GPUs, as well as machines with a lot of CPU cores and RAM! See Compute Servers for details.

Widgets

Jupyter Widgets are Python objects that let you build interactive GUIs for your Jupyter notebooks. A good way to get started using Jupyter widgets is to go through the Widget List. In CoCalc widgets are fully collaborative, meaning that you and your collaborators share and see exactly the same state of them. This is different from most other platforms, where changes to controls made by one user are not visible to another.

notebook with widgets

CoCalc Jupyter notebook with Jupyter Widgets

For more information on the implementation watch πŸ“Ί Jupyter Widgets in CoCalc.

Protect Cells

You can protect cells from being modified or deleted using Edit > Protect menu. Note that this only prevents accidental edit and delete operations via regular interface. It is easy to bypass this protection using other means or turn it off via Edit > Remove Protection.

Slideshow

To make a slideshow from a Jupyter Notebook, select View > Cell Toolbar > Slideshow toolbar to add a selector at the top right of each cell and specify whether it is a slide, subslide, or fragment. To view the slideshow, select File > Slideshow or split the frame and change one of the resulting frames to Slideshow.

Cell Type for Slides Selector

Cell Type for Slides Selector

When presenting, the next Slide is to the right, while the next Subslide is below. Fragments are revealed within the present slide. Click in the slideshow and then click ? to see a list of keyboard shortcuts. If you modify the notebook, you can update the slideshow by clicking Build in the toolbar above or by selecting File > Slideshow again.

Slideshow Mode

Slideshow Mode

Play a WAV File

CoCalc Jupyter Notebooks support embedding audio files.

WAV File on Disk

  1. Create a file on disk, e.g. tuba.wav. If you’re using simpleaudio or something else to create sound, make sure to figure out how to save that sound to a local file.

  2. Put this in the markdown cell and hit Shift + Enter:

    <audio controls=true src="tuba.wav"/>
    
  3. You will see an embedded audio controller appear and you can play your audio.

Audio Controls to Play WAV File

Audio Controls to Play WAV File

Embedded WAV File

Alternatively, you might want the file to be embedded in the notebook itself. To do this, click the picture icon on the right of a markdown cell or click Edit > Insert images in …, then drag and drop to copy the WAV file as an attachment to that cell. Then replace the image attachment code that is generated by:

<audio controls=true src="attachment:tuba.wav"/>

You will see a player and can play your file.

Customize LaTeX Export Settings

Cocalc exports Jupyter notebooks to LaTeX using nbconvert when File > PDF via LaTeX is clicked in the menu. If you want to customize the default LaTeX settings, you need to override system files found at /ext/jupyter/nbconvert/templates/latex Instructions for creating these overrides can be found in this gist file: custom nbconvert exports