この記事の目次
chevron_right
Model
chevron_right
Python
chevron_right
公式どおりにやってみる
chevron_right
AssertionError: Torch not compiled with CUDA enabledの解決
著作権的にはよくわからんので、やるなら自己責任でお願いします。
とりあえず動かすところまで。
Model
https://huggingface.co/cagliostrolab/animagine-xl-3.1
Python
- Python 3.11
scoop使って入れてます。
> scoop bucket add versions
> scoop install python311
> python311 -V
venvも作ります
> python311 -m venv venv
公式どおりにやってみる
> pip install diffusers transformers accelerate safetensors --upgrade
import torch
from diffusers import DiffusionPipeline
pipe = DiffusionPipeline.from_pretrained(
"cagliostrolab/animagine-xl-3.1",
torch_dtype=torch.float16,
use_safetensors=True,
)
pipe.to('cuda')
prompt = "1girl, souryuu asuka langley, neon genesis evangelion, solo, upper body, v, smile, looking at viewer, outdoors, night"
negative_prompt = "nsfw, lowres, (bad), text, error, fewer, extra, missing, worst quality, jpeg artifacts, low quality, watermark, unfinished, displeasing, oldest, early, chromatic aberration, signature, extra digits, artistic error, username, scan, [abstract]"
image = pipe(
prompt,
negative_prompt=negative_prompt,
width=832,
height=1216,
guidance_scale=7,
num_inference_steps=28
).images[0]
image.save("./output/test.png")
> python ./main.py
AssertionError: Torch not compiled with CUDA enabled
とでる
AssertionError: Torch not compiled with CUDA enabled
の解決
以下記事参考
https://qiita.com/sakusaku3939/items/1a133729c7f38e8403ce
> pip uninstall torch torchvision torchaudio
> pip cache purge
> pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
再度実行
> python ./main.py
一応これでできました。
この記事はあくまでPythonでanimagine-xl-3.1
のModelを利用することを目的としているため、
著作権侵害を助長するものではありません。

この記事を書いた人
Nな人(えぬなひと)。
Nは本名から取っています。
Laravelが大好きなPHPerで、WEBを作るときはLaravelを技術スタックに絶対推すマン。
PHP、Pythonと、昔はperlを書いていたP言語エンジニア。
最近はNimを書いたりしています。
Nは本名から取っています。
Laravelが大好きなPHPerで、WEBを作るときはLaravelを技術スタックに絶対推すマン。
PHP、Pythonと、昔はperlを書いていたP言語エンジニア。
最近はNimを書いたりしています。