Content-Length: 373097 | pFad | http://github.com/hecrj/icebreaker/pull/6/commits/912f5b2de69f5984957c6f2f01016f23600eb835

DD Add ROCm support by pml68 · Pull Request #6 · hecrj/icebreaker · GitHub
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ROCm support #6

Merged
merged 4 commits into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactor Backend in assistant a bit
And disable the "Use GPU" toggler if no GPU is
detected.
  • Loading branch information
hecrj committed Feb 1, 2025
commit 912f5b2de69f5984957c6f2f01016f23600eb835
23 changes: 13 additions & 10 deletions src/data/assistant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ impl Assistant {
volume = Self::MODELS_DIR,
)
}
Backend::Gpu(GpuBackend::Cuda) => {
Backend::Cuda => {
format!(
"create --rm --gpus all -p {port}:80 -v {volume}:/models \
{container} --model /models/{filename} \
Expand All @@ -233,7 +233,7 @@ impl Assistant {
volume = Self::MODELS_DIR,
)
}
Backend::Gpu(GpuBackend::Rocm) => {
Backend::Rocm => {
format!(
"create --rm -p {port}:80 -v {volume}:/models \
--device=/dev/kfd --device=/dev/dri \
Expand Down Expand Up @@ -497,7 +497,7 @@ impl Assistant {
) -> Result<process::Child, Error> {
let gpu_flags = match backend {
Backend::Cpu => "",
Backend::Gpu(_) => "--gpu-layers 80",
Backend::Cuda | Backend::Rocm => "--gpu-layers 80",
};

let server = process::Command::new(executable)
Expand Down Expand Up @@ -525,24 +525,27 @@ impl Assistant {
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Backend {
Cpu,
Gpu(GpuBackend),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum GpuBackend {
Rocm,
Cuda,
Rocm,
}

impl Backend {
pub fn detect(graphics_adapter: &str) -> Self {
if graphics_adapter.contains("NVIDIA") {
Self::Gpu(GpuBackend::Cuda)
Self::Cuda
} else if graphics_adapter.contains("AMD") {
Self::Gpu(GpuBackend::Rocm)
Self::Rocm
} else {
Self::Cpu
}
}

pub fn uses_gpu(self) -> bool {
match self {
Backend::Cuda | Backend::Rocm => true,
Backend::Cpu => false,
}
}
}

#[derive(Debug, Clone)]
Expand Down
25 changes: 14 additions & 11 deletions src/screen/boot.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::data::assistant::{Backend, File, GpuBackend, Model};
use crate::data::assistant::{Backend, File, Model};
use crate::widget::tip;

use iced::system;
Expand All @@ -13,7 +13,7 @@ pub struct Boot {
file: Option<File>,
readme: Vec<markdown::Item>,
use_gpu: bool,
backend: Backend,
supported_backend: Backend,
}

#[derive(Debug, Clone)]
Expand All @@ -34,9 +34,10 @@ pub enum Action {

impl Boot {
pub fn new(model: Model, system: Option<&system::Information>) -> (Self, Task<Message>) {
let backend = system
let supported_backend = system
.map(|system| Backend::detect(&system.graphics_adapter))
.unwrap_or(Backend::Cpu);

(
Self {
model: model.clone(),
Expand All @@ -46,8 +47,8 @@ impl Boot {
None
},
readme: Vec::new(),
use_gpu: matches!(backend, Backend::Gpu(_)),
backend,
use_gpu: supported_backend.uses_gpu(),
supported_backend,
},
Task::future(model.fetch_readme())
.and_then(|readme| {
Expand Down Expand Up @@ -81,10 +82,10 @@ impl Boot {
if let Some(file) = self.file.clone() {
Action::Boot {
file,
backend: if self.use_gpu && !matches!(self.backend, Backend::Gpu(_)) {
Backend::Gpu(GpuBackend::Cuda)
backend: if self.use_gpu {
self.supported_backend
} else {
self.backend
Backend::Cpu
},
}
} else {
Expand All @@ -110,9 +111,11 @@ impl Boot {

let boot = {
let use_cuda = {
let toggle = toggler(self.use_gpu)
.label("Use GPU")
.on_toggle(Message::UseGPUToggled);
let toggle = toggler(self.use_gpu).label("Use GPU").on_toggle_maybe(
self.supported_backend
.uses_gpu()
.then_some(Message::UseGPUToggled),
);

tip(
toggle,
Expand Down








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/hecrj/icebreaker/pull/6/commits/912f5b2de69f5984957c6f2f01016f23600eb835

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy