Notebook Usage Guide

GitCode AI Notebook provides a powerful online development environment, allowing you to perform data analysis, model training, and experiments directly in your browser. This guide will help you understand how to use Notebook features.

Notebook Startup

Create New Notebook

  1. Login to your GitCode AI account
  2. Go to “Notebook” > “New Notebook”
  3. Select environment configuration:
    • Python version
    • CUDA version (if GPU needed)
    • Pre-installed frameworks
  4. Select computing resources:
    • CPU cores
    • Memory size
    • GPU type (optional)
  5. Click “Start”

[Image: Notebook creation page screenshot]

Environment Configuration

You can predefine the environment through notebook-config.yaml:

name: my-notebook
version: 1.0.0
python_version: "3.9"
cuda_version: "11.7"
packages:
  - torch>=2.0.0
  - transformers>=4.30.0
  - pandas>=2.0.0
resources:
  cpu: 4
  memory: 16GB
  gpu: "T4"

Notebook Usage

Basic Operations

  1. File Management

    • Create new files
    • Upload files
    • Export notebook
    • Version control
  2. Editing Features

    • Code completion
    • Syntax highlighting
    • Real-time error checking
    • Shortcut key support
  3. Execution Control

    • Run single cell
    • Run all
    • Restart kernel
    • Interrupt execution

Code Examples

# Import common libraries
import torch
import pandas as pd
import matplotlib.pyplot as plt

# Data visualization
%matplotlib inline
plt.style.use('seaborn')

# Show progress bar
from tqdm.notebook import tqdm

# Use GPU
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')

Magic Commands

# Show all magic commands
%lsmagic

# Timing
%%time
# your code here

# Show variables
%who

# Run shell commands
!pip install package-name

Advanced Features

Remote Storage Integration

# Mount cloud storage
!gitcode mount storage://my-bucket /mnt/data

# Read data
import pandas as pd
df = pd.read_csv('/mnt/data/dataset.csv')

Model Training Monitoring

# Use TensorBoard
%load_ext tensorboard
%tensorboard --logdir runs/

# Custom progress display
from gitcode.tracking import track_progress

@track_progress
def train_epoch():
    # training code
    pass

Resource Monitoring

# Show GPU usage
!nvidia-smi

# Show system resources
!top -n 1

# Show disk usage
!df -h

Best Practices

  1. Code Organization

    • Use Markdown to add explanations
    • Modular code structure
    • Save work regularly
    • Add comments
  2. Resource Management

    • Release memory promptly
    • Use generators for large data
    • Use cache reasonably
    • Close unused kernels
  3. Version Control

    • Commit changes regularly
    • Use meaningful commit messages
    • Create checkpoints
    • Backup important data
  4. Collaborative Development

    • Share notebooks
    • Add documentation
    • Use unified code style
    • Sync changes promptly

Common Questions

Q: How to install additional packages? A: You can use !pip install package-name or predefine in configuration files.

Q: What kernels does Notebook support? A: Supports multiple programming language kernels including Python, R, Julia, etc.

Q: How to handle insufficient memory? A: You can use generators, clean variables, or upgrade resource configuration.

Q: How to share Notebook? A: You can share through sharing links, export files, or collaboration mode.

Shortcut Key Reference

FunctionWindows/LinuxMac
Run cellShift + EnterShift + Return
Add cellBB
Delete cellD, DD, D
Toggle MarkdownMM
Save fileCtrl + SCmd + S
Interrupt executionI, II, I