Closed ahrnbom closed 7 months ago
After a lot more experimentation, it seems that tilemapgen can indeed be installed, but only if you install pytorch3d version 0.7.4 via pip, in the way that is described for Google Colab on Pytorch3d's installation instructions, and then modify tilemapgen to not require an outdated version of torch and torchvision. I will explore this a bit further and build something that's easy to use. Do you want me to make a PR with my fixes? Otherwise I might just make a fork
I can at least confirm that the following setup does work. I will do some work to clean this up in a few days, not sure how to distribute it. Since there hasn't been any response here, I think a fork probably makes sense.
Anyway, my current hacky fix is to create the following files in some folder:
Dockerfile
:
FROM pytorch/pytorch:2.2.1-cuda12.1-cudnn8-runtime
# Install dependencies of pytorch3d and tilemapgen
RUN python3 -m pip install fvcore iopath transformers diffusers accelerate huggingface-hub numpy pillow safetensors pyrallis
# Figure out which build of pytorch3d to install
COPY pytorch3d-version.py /pt3dv.py
RUN VER=$(python3 /pt3dv.py) && pip install --no-index --no-cache-dir pytorch3d==0.7.6 -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/$VER/download.html
# Install apt stuff
RUN apt-get update && apt-get install -y git && apt-get clean
# Fix and then install tilemapgen
COPY fix-tilemapgen.py /fix-tmg.py
RUN git clone https://github.com/charmed-ai/tilemapgen.git /tmp/tmg && python3 /fix-tmg.py && pip install -e /tmp/tmg
fix-tilemapgen.py
:
from pathlib import Path
reqs = Path("/tmp/tmg/requirements.txt")
assert reqs.is_file()
Path("/tmp/tmg/environment.yml").unlink()
new_reqs_text = f"""
transformers
diffusers
accelerate
huggingface-hub
iopath
numpy
pillow
safetensors
pyrallis
"""
reqs.write_text(new_reqs_text)
setup = Path("/tmp/tmg/setup.py")
assert setup.is_file()
new_setup_text="""
#!/usr/bin/env python
from distutils.core import setup
setup(name='tilemapgen',
version='0.0.1',
description='Generate isometric tilemaps from text prompts',
author='Jeremy Tryba',
author_email='jeremy@charmed.ai',
url='https://github.com/charmed-ai/tilemap-generator/',
packages=['tilemapgen'],
package_dir={'': 'src'},
py_modules=['tilemapgen'],
install_requires=[
'torch',
'torchvision',
'transformers',
'diffusers',
'pyrallis',
'pytorch3d'
],
scripts=['scripts/tilemapgen'],
)
"""
setup.write_text(new_setup_text)
pytorch3d-version
:
import sys
import torch
pyt_version_str=torch.__version__.split("+")[0].replace(".", "")
version_str="".join([
f"py3{sys.version_info.minor}_cu",
torch.version.cuda.replace(".",""),
f"_pyt{pyt_version_str}"
])
print(version_str)
run.sh
:
docker build --tag tmg:latest . && \
docker run --rm --gpus all --name tilemapgen --mount type=bind,source="$(pwd)"/mounted,target=/mounted -it tmg:latest bash
For anyone interested, the fork is available here: https://github.com/ahrnbom/tilemapgen-good
Hi!
I have spent a few days trying to install tilemapgen, but failed. I think the
Readme.md
instructions might be out of date, or that therequirements.txt
orenvironment.yml
needs to be updated? Or maybe I'm just doing something wrong.I am using Docker to try to install this, to allow me to try multiple different approaches without breaking my system. I have been using
continuumio/miniconda3
as a base, but perhaps that is a bad idea. Do you have any suggestions? Any help is much appreciated. If there's anything I can help with, like updating documentation or configuration files, I will gladly help and make a PR or something (assuming I can solve it, at least).Here is a summary of a handful of the things I have tried:
Attempt 1
Trying to install from pip. First, I install pytorch3d by
which, in itself seems to work, my pytorch is now CUDA enabled. It does install torch 2.1.0 though, which is not the same as what tilemapgen wants.
Regardless, I try installing via pip as
This overwrites PyTorch with 2.0.1 (still CUDA enabled). PyTorch3d 0.7.5 is still installed.
Trying to run it gives the following error:
This is somewhat cryptic, but I assume the pip package is incorrectly configured somehow. It doesn't seem to find its command_definitions module.
Attempt 2
Trying to install from source code on GitHub. Running
conda env create -f environment.yml
does seemingly work, but it installs a version of PyTorch not compiled with CUDA support. Everything seems to work, except it runs on the CPU, so it takes forever to render anything. Presumably, something is wrong inenvironment.yml
that makesconda
grab a CPU-only build of PyTorch from a "priority channel".Attempt 3
Like attempt 1, but I try a more compact installation of pytorch3d. The idea being that if I can install everything in one line, I can make a modification to
environment.yml
to get it to install.This does not work, as PyTorch will be CPU only (not sure why?)
I guess this is somewhat similar to what
conda env create -f environment.yml
does under the hood, trying to install it all at once. I can cofirm that removing "pytorch3d" from this command will indeed give you the CUDA version of PyTorch.Attempt 4
Trying to single-line install both pytorch (CUDA) and PyTorch3d. The idea is, if I can do this, I can modify
environment.yml
to actually work.seems like the right approach but conflicting versions of Python? I have tried this on 3.12 (didn't work) 3.11 (didn't work) 3.10 (didn't work) 3.9 (didn't work) 3.8 (didn't work)
If I add
-c conda-forge
, it is always able to find a solution, but it also always picks CPU build of PyTorch.Should enforce CUDA-built PyTorch, but it doesn't work as-is on 3.11 at least. On 3.10 it gets stuck on "solving environment" forever (multiple hours)
does kind of work, but
from pytorch3d import _C
does crash with aso it seems unlikely that tilemapgen will work. Nonetheless, let's try. Modified
requirements.txt
to only beand then ran
pip install -e .
. It does seem to download torch 2.0.1, which is worrying.Result is
Attempt 5
Try to not actually install tilemapgen, but instead only install requirements, manually through conda and/or pip, and then try to just run tilemapgen.
missing only
huggingface-hub
andpyrallis
Tried some variants, but conda wasn't able to figure it outInstaller runs, but cannot even import torch