User Tools

Site Tools


examples

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
examples [2025/03/31 21:55] – created nshegunovexamples [2025/03/31 22:28] (current) nshegunov
Line 1: Line 1:
-  - PyTorch Example:+====MPI4PI==== 
 +TOD 
 + 
 +---- 
 +==== PyTorch==== 
 +Consider the following simple python test script( "pytorch_test.py"): 
 + 
 <code python> <code python>
 import torch import torch
Line 19: Line 25:
     print("Tensor operation result:", z)     print("Tensor operation result:", z)
  
-    test_pytorch() +test_pytorch() 
-<\code>+</code> 
 + 
 +To test it on the unite cluster you can use the folling sbatch scrpit to run it: 
 +<code bash> 
 +#!/bin/bash 
 +#SBATCH --job-name=pytorch_test 
 +#SBATCH --output=pytorch_test.out 
 +#SBATCH --error=pytorch_test.err 
 +#SBATCH --time=00:10:00 
 +#SBATCH --partition=a40 
 +#SBATCH --gres=gpu:
 +#SBATCH --mem=4G 
 +#SBATCH --cpus-per-task=2 
 + 
 +# Load necessary modules (modify based on your system) 
 +module load python/pytorch-2.5.1-llvm-cuda-12.3-python-3.13.1-llvm 
 + 
 +# Activate your virtual environment if needed 
 +# source ~/your_env/bin/activate 
 + 
 +# Run the PyTorch script 
 +python3.13 pytorch_test.py 
 + 
 +</code> 
 +---- 
 +====Pandas==== 
 +Consider the following simple python test script( “pandas_test.py”): 
 +<code python> 
 +import pandas as pd 
 +import numpy as np 
 + 
 +# Create a simple DataFrame 
 +data = { 
 +    'A': [1, 2, 3, 4], 
 +    'B': [5, 6, 7, 8], 
 +    'C': [9, 10, 11, 12] 
 +
 +df = pd.DataFrame(data) 
 +print("Original DataFrame:"
 +print(df) 
 + 
 +# Test basic operations 
 +print("\nSum of each column:"
 +print(df.sum()) 
 + 
 +print("\nMean of each column:"
 +print(df.mean()) 
 + 
 +# Adding a new column 
 +df['D'] = df['A'] + df['B'
 +print("\nDataFrame after adding new column D (A + B):"
 +print(df) 
 + 
 +# Filtering rows 
 +filtered_df = df[df['A'] > 2] 
 +print("\nFiltered DataFrame (A > 2):"
 +print(filtered_df) 
 + 
 +# Check if NaN values exist 
 +print("\nCheck for NaN values:"
 +print(df.isna().sum()) 
 +</code> 
 + 
 +You can use the following snatch script to run it: 
 +<code bash> 
 +#!/bin/bash 
 +#SBATCH --job-name=pytorch_test 
 +#SBATCH --output=pytorch_test.out 
 +#SBATCH --error=pytorch_test.err 
 +#SBATCH --time=00:10:00 
 +#SBATCH --partition=a40 
 +#SBATCH --gres=gpu:
 +#SBATCH --mem=4G 
 +#SBATCH --cpus-per-task=2 
 + 
 +# Load necessary modules (modify based on your system) 
 +module load python/3.13.1-llvm 
 +module load python/3.13/pandas/2.2.3
  
 +# Activate your virtual environment if needed
 +# source ~/your_env/bin/activate
  
 +# Run the PyTorch script
 +python3.13 pandas_test.py
 +</code>
 +----
 +====Other popular====
 +TOD
examples.1743458124.txt.gz · Last modified: 2025/03/31 21:55 by nshegunov

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki