Skip to content

Commit

Permalink
adding example
Browse files Browse the repository at this point in the history
  • Loading branch information
noahgift committed Mar 28, 2023
1 parent ecaf7ae commit 18eea70
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pytorch-rust-docker/chatgpt-pytorch/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "chatgpt-pytorch"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tch = "0.11.0"

18 changes: 18 additions & 0 deletions pytorch-rust-docker/chatgpt-pytorch/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Use the official Rust image as the base image
FROM rust:1.67

# Set the working directory
WORKDIR /app

# Install system dependencies required by PyTorch and tch-rs
RUN apt-get update && \
apt-get install -y build-essential python3-dev python3-pip libopenblas-dev libopencv-dev

# Copy the Rust project into the container
COPY . .

# Build the Rust project
RUN cargo build --release

# Set the command to run the binary
CMD ["./target/release/chatgpt_pytorch"]
6 changes: 6 additions & 0 deletions pytorch-rust-docker/chatgpt-pytorch/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use tch::{Tensor, Kind};

fn main() {
let tensor = Tensor::of_slice(&[1, 2, 3, 4]).reshape(&[2, 2]).to_kind(Kind::Float);
println!("Tensor: {:?}", tensor);
}

0 comments on commit 18eea70

Please sign in to comment.