Closed DanielZanchi closed 1 year ago
For Apple silicon you need to run the following before building cog:
export DOCKER_DEFAULT_PLATFORM=linux/amd64
Thanks for the reply. Getting this now:
cog-faceswap-main % cog predict -i target_image=@tony.jpg -i swap_image=@elon.jpg
Building Docker image from environment in cog.yaml...
[+] Building 1.8s (21/21) FINISHED docker:desktop-linux
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 2.27kB 0.0s
=> resolve image config for docker.io/docker/dockerfile:1.4 0.9s
=> CACHED docker-image://docker.io/docker/dockerfile:1.4@sha256:9ba7531bd80fb0a858632727cf7a112fbfd19b17e94c4e84ced81e24ef1a0dbc 0.0s
=> [internal] load metadata for docker.io/nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04 0.7s
=> [internal] load build context 0.0s
=> => transferring context: 83.78kB 0.0s
=> [stage-0 1/13] FROM docker.io/nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04@sha256:b856c89aa26c1dc1b56c834a66b44c527a298325173c87291486fc100ceedb6e 0.0s
=> CACHED [stage-0 2/13] RUN --mount=type=cache,target=/var/cache/apt set -eux; apt-get update -qq; apt-get install -qqy --no-install-recommends curl; rm -rf /var/lib/apt/lists/*; TINI_VERSION=v0.19.0; TINI_ARCH="$(dpkg --print-architecture)"; curl -sSL -o /sbin/tini "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-${TINI_ARCH}"; chmod +x /sbin/t 0.0s
=> CACHED [stage-0 3/13] RUN --mount=type=cache,target=/var/cache/apt apt-get update -qq && apt-get install -qqy --no-install-recommends make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev git ca-certificates && rm -rf /var/lib/apt/ 0.0s
=> CACHED [stage-0 4/13] RUN curl -s -S -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash && git clone https://github.com/momo-lab/pyenv-install-latest.git "$(pyenv root)"/plugins/pyenv-install-latest && pyenv install-latest "3.8" && pyenv global $(pyenv install-latest --print "3.8") && pip install "wheel<1" 0.0s
=> CACHED [stage-0 5/13] COPY .cog/tmp/build3659661191/cog-0.0.1.dev-py3-none-any.whl /tmp/cog-0.0.1.dev-py3-none-any.whl 0.0s
=> CACHED [stage-0 6/13] RUN --mount=type=cache,target=/root/.cache/pip pip install /tmp/cog-0.0.1.dev-py3-none-any.whl 0.0s
=> CACHED [stage-0 7/13] RUN --mount=type=cache,target=/var/cache/apt apt-get update -qq && apt-get install -qqy cmake zip ffmpeg libsm6 libxext6 && rm -rf /var/lib/apt/lists/* 0.0s
=> CACHED [stage-0 8/13] COPY .cog/tmp/build3659661191/requirements.txt /tmp/requirements.txt 0.0s
=> CACHED [stage-0 9/13] RUN --mount=type=cache,target=/root/.cache/pip pip install -r /tmp/requirements.txt 0.0s
=> CACHED [stage-0 10/13] RUN mkdir -p /root/.insightface/models/buffalo_l/ 0.0s
=> CACHED [stage-0 11/13] RUN wget https://github.com/deepinsight/insightface/releases/download/v0.7/buffalo_l.zip 0.0s
=> CACHED [stage-0 12/13] RUN unzip buffalo_l.zip -d /root/.insightface/models/buffalo_l 0.0s
=> CACHED [stage-0 13/13] WORKDIR /src 0.0s
=> preparing layers for inline cache 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:975818db4d49f01673563519c9f1084272ebb7915e9f8823830c91e2476dc841 0.0s
=> => naming to docker.io/library/cog-faceswap-main-base 0.0s
Starting Docker image cog-faceswap-main-base and running setup()...
docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]].
Missing device driver, re-trying without GPU
Error response from daemon: page not found
/root/.pyenv/versions/3.8.18/lib/python3.8/site-packages/torchvision/transforms/functional_tensor.py:5: UserWarning: The torchvision.transforms.functional_tensor module is deprecated in 0.15 and will be **removed in 0.17**. Please don't rely on it. You probably just need to use APIs in torchvision.transforms.functional or in torchvision.transforms.v2.functional.
warnings.warn(
/root/.pyenv/versions/3.8.18/lib/python3.8/site-packages/torchvision/transforms/functional_tensor.py:5: UserWarning: The torchvision.transforms.functional_tensor module is deprecated in 0.15 and will be **removed in 0.17**. Please don't rely on it. You probably just need to use APIs in torchvision.transforms.functional or in torchvision.transforms.v2.functional.
warnings.warn(
2023-10-31 08:52:48.610726679 [W:onnxruntime:, graph.cc:3553 CleanUnusedInitializersAndNodeArgs] Removing initializer 'buff2fs'. It is not used by any node and should be removed from the model.
2023-10-31 08:52:50.714907597 [W:onnxruntime:, graph.cc:3553 CleanUnusedInitializersAndNodeArgs] Removing initializer 'buff2fs'. It is not used by any node and should be removed from the model.
EP Error /onnxruntime_src/onnxruntime/core/session/provider_bridge_ort.cc:1193 onnxruntime::Provider& onnxruntime::ProviderLibrary::Get() [ONNXRuntimeError] : 1 : FAIL : Failed to load library libonnxruntime_providers_tensorrt.so with error: libnvinfer.so.8: cannot open shared object file: No such file or directory
when using ['TensorrtExecutionProvider', 'CUDAExecutionProvider', 'AzureExecutionProvider', 'CPUExecutionProvider']
Falling back to ['CUDAExecutionProvider', 'CPUExecutionProvider'] and retrying.
Traceback (most recent call last):
File "/root/.pyenv/versions/3.8.18/lib/python3.8/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 419, in __init__
self._create_inference_session(providers, provider_options, disabled_optimizers)
File "/root/.pyenv/versions/3.8.18/lib/python3.8/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 463, in _create_inference_session
sess.initialize_session(providers, provider_options, disabled_optimizers)
RuntimeError: /onnxruntime_src/onnxruntime/core/session/provider_bridge_ort.cc:1193 onnxruntime::Provider& onnxruntime::ProviderLibrary::Get() [ONNXRuntimeError] : 1 : FAIL : Failed to load library libonnxruntime_providers_tensorrt.so with error: libnvinfer.so.8: cannot open shared object file: No such file or directory
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/root/.pyenv/versions/3.8.18/lib/python3.8/site-packages/cog/server/worker.py", line 185, in _setup
run_setup(self._predictor)
File "/root/.pyenv/versions/3.8.18/lib/python3.8/site-packages/cog/predictor.py", line 66, in run_setup
predictor.setup()
File "predict.py", line 16, in setup
self.face_swapper = insightface.model_zoo.get_model('cache/inswapper_128.onnx', providers=onnxruntime.get_available_providers())
File "/root/.pyenv/versions/3.8.18/lib/python3.8/site-packages/insightface/model_zoo/model_zoo.py", line 96, in get_model
model = router.get_model(providers=providers, provider_options=provider_options)
File "/root/.pyenv/versions/3.8.18/lib/python3.8/site-packages/insightface/model_zoo/model_zoo.py", line 40, in get_model
session = PickableInferenceSession(self.onnx_file, **kwargs)
File "/root/.pyenv/versions/3.8.18/lib/python3.8/site-packages/insightface/model_zoo/model_zoo.py", line 25, in __init__
super().__init__(model_path, **kwargs)
File "/root/.pyenv/versions/3.8.18/lib/python3.8/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 430, in __init__
raise fallback_error from e
File "/root/.pyenv/versions/3.8.18/lib/python3.8/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 425, in __init__
self._create_inference_session(self._fallback_providers, None)
File "/root/.pyenv/versions/3.8.18/lib/python3.8/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 463, in _create_inference_session
sess.initialize_session(providers, provider_options, disabled_optimizers)
RuntimeError: /onnxruntime_src/onnxruntime/core/providers/cuda/cuda_call.cc:121 std::conditional_t<THRW, void, onnxruntime::common::Status> onnxruntime::CudaCall(ERRTYPE, const char*, const char*, ERRTYPE, const char*, const char*, int) [with ERRTYPE = cudaError; bool THRW = true; std::conditional_t<THRW, void, onnxruntime::common::Status> = void] /onnxruntime_src/onnxruntime/core/providers/cuda/cuda_call.cc:114 std::conditional_t<THRW, void, onnxruntime::common::Status> onnxruntime::CudaCall(ERRTYPE, const char*, const char*, ERRTYPE, const char*, const char*, int) [with ERRTYPE = cudaError; bool THRW = true; std::conditional_t<THRW, void, onnxruntime::common::Status> = void] CUDA failure 35: CUDA driver version is insufficient for CUDA runtime version ; GPU=764642560 ; hostname=e56efa1b9238 ; file=/onnxruntime_src/onnxruntime/core/providers/cuda/cuda_execution_provider.cc ; line=236 ; expr=cudaSetDevice(info_.device_id);
ⅹ Model setup failed
Ah, my assumption was that you just needed to build the cog model on your apple silicon mac to push to Replicate. Afaik you cant run this model locally as is, because apple silicon doesnt have an nvidia driver and the model is looking for CUDA. You might have to remove all instances of cuda and torch, but Im not sure.
I'm on a MBP with M1 and during the command:
cog build -t faceswap
i got this error: