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
- Login to your GitCode AI account
- Go to “Notebook” > “New Notebook”
- Select environment configuration:
- Python version
- CUDA version (if GPU needed)
- Pre-installed frameworks
- Select computing resources:
- CPU cores
- Memory size
- GPU type (optional)
- 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
File Management
- Create new files
- Upload files
- Export notebook
- Version control
Editing Features
- Code completion
- Syntax highlighting
- Real-time error checking
- Shortcut key support
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
Code Organization
- Use Markdown to add explanations
- Modular code structure
- Save work regularly
- Add comments
Resource Management
- Release memory promptly
- Use generators for large data
- Use cache reasonably
- Close unused kernels
Version Control
- Commit changes regularly
- Use meaningful commit messages
- Create checkpoints
- Backup important data
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
Function | Windows/Linux | Mac |
---|---|---|
Run cell | Shift + Enter | Shift + Return |
Add cell | B | B |
Delete cell | D, D | D, D |
Toggle Markdown | M | M |
Save file | Ctrl + S | Cmd + S |
Interrupt execution | I, I | I, I |