docker buildx -t localai .
It seems like you’re trying to use the Docker Buildx command to build a Docker image with the tag “localai”. Docker Buildx is a tool that extends the capabilities of the Docker CLI to support building Docker images for multiple platforms and architectures.
Before running the command you mentioned, ensure that you have Docker installed and that you have Buildx enabled. If you don’t have Buildx enabled, you can enable it by running the following command:
“`bash
docker buildx create –use
“`
Now, let’s break down the command you provided:
“`bash
docker buildx -t localai .
“`
Here’s what each part of the command means:
– `docker`: This is the Docker CLI command used to interact with Docker.
– `buildx`: This is the sub-command for Docker Buildx.
– `-t localai`: This specifies the tag for the Docker image that will be built. The tag allows you to give your image a meaningful name that you can use to identify it later.
– `.`: This indicates the build context. The build context is the path to the directory containing the Dockerfile and any files required for building the Docker image.
Assuming you have the Dockerfile present in the current directory, running the above command will start the Docker image building process with Buildx, using the specified tag “localai”.
If you encounter any issues during the build process, double-check that you have Docker and Buildx correctly set up and that your Dockerfile is correctly written.
Also, keep in mind that the command provided here is valid as of my knowledge cutoff date in September 2021. Docker and its tooling may evolve over time, so it’s possible that newer versions or changes in Docker could affect the exact usage of the command.
docker buildx create –use
doesn’t run
I apologize for any confusion. The command `docker buildx create –use` is used to create and set up a new Buildx builder instance and switch to using it as the default builder. This command should indeed be valid if you have Docker Buildx properly installed and enabled.
If you encounter an issue where the command is not running, here are a few troubleshooting steps you can try:
1. **Check Buildx Installation**: First, ensure that you have Docker Buildx installed on your system. Buildx is an optional Docker CLI plugin, and it might not be included by default in some older Docker installations. You can check if Buildx is installed by running:
“`bash
docker buildx version
“`
If Buildx is not installed, you may need to install it separately. Refer to the official Docker documentation for installation instructions specific to your operating system.
2. **Check Docker Version**: Make sure you are using a version of Docker that supports Buildx. Buildx was introduced as a Docker CLI plugin starting from Docker 19.03. If you are using an older version, you may need to upgrade Docker.
3. **Enable Experimental Features**: Buildx is part of Docker’s experimental features. Ensure that experimental features are enabled in your Docker configuration. To enable experimental features, modify your Docker daemon configuration file (typically located at `/etc/docker/daemon.json`) to include:
“`json
{
“experimental”: true
}
“`
After making this change, restart the Docker daemon.
4. **Check Permissions**: Ensure that you have the necessary permissions to run Docker commands. On most systems, you need to be part of the `docker` group to execute Docker commands without using `sudo`. You can add your user to the `docker` group by running:
“`bash
sudo usermod -aG docker $USER
“`
After adding your user to the `docker` group, you might need to log out and log back in for the changes to take effect.
5. **Restart Docker Service**: If you made any changes to Docker configuration or permissions, restart the Docker service:
“`bash
sudo service docker restart
“`
Once you have checked and addressed any potential issues with the Docker and Buildx setup, try running the `docker buildx create –use` command again. If everything is set up correctly, it should create a new Buildx builder instance and switch to using it as the default builder.
(base) gemini@DESKTOP-UNG8TH9:/mnt/d/SuperAGi$ docker buildx version
github.com/docker/buildx v0.11.0 687feca9e8dcd1534ac4c026bc4db5a49de0dd6e
Great! It looks like you have Docker Buildx installed, and its version is v0.11.0, as indicated by the output `github.com/docker/buildx v0.11.0 687feca9e8dcd1534ac4c026bc4db5a49de0dd6e`.
Now, you can proceed to create a new builder instance and set it as the default builder using the `docker buildx create –use` command. This will enable you to take advantage of the extended features provided by Buildx for building multi-platform Docker images.
Remember that the `docker buildx create –use` command needs to be executed in your terminal or command prompt, and you should have the necessary permissions to run Docker commands without using `sudo` (or appropriate elevated privileges).
Once you have run the `docker buildx create –use` command, you can then use the `docker buildx` command with its extended capabilities, such as building images for different platforms, efficiently pushing to registries, and more.
If you encounter any issues during the process, feel free to share the specific problem you’re facing, and I’ll be glad to assist you further!
no worky
I apologize for the confusion and any inconvenience you’ve experienced. Let’s try troubleshooting the issue step by step:
1. **Check Docker Version**: Ensure that you have Docker installed and that it’s at least version 19.03 or later, as Docker Buildx was introduced as a CLI plugin from Docker version 19.03 onwards. To check your Docker version, run:
“`bash
docker version
“`
Make sure the client version is 19.03 or higher.
2. **Enable Experimental Features**: Docker Buildx is an experimental feature, and you need to enable it explicitly. Ensure that experimental features are enabled in your Docker configuration. Modify your Docker daemon configuration file (typically located at `/etc/docker/daemon.json`) to include:
“`json
{
“experimental”: true
}
“`
After making this change, restart the Docker daemon:
“`bash
sudo service docker restart
“`
3. **Check Buildx Installation**: Verify that Docker Buildx is installed and available by running:
“`bash
docker buildx version
“`
Ensure you get output similar to what you previously shared, showing the Buildx version.
4. **Create and Use Buildx Builder**: If everything seems fine so far, let’s try creating a new Buildx builder instance and setting it as the default. Run the following command:
“`bash
docker buildx create –use
“`
If the command executes successfully, you should see output indicating that a new builder instance has been created and is now in use.
5. **Verify Builder**: To double-check that the builder is active, run:
“`bash
docker buildx ls
“`
This command should display the list of active builder instances, and the one you just created should be marked with “(in use)”.
If you encounter any errors or unexpected behavior during these steps, please provide the specific error messages or outputs you receive, so I can assist you further. Additionally, if you have any other relevant information about your system or configuration, it would be helpful for troubleshooting.
Dockerfile:44
——————–
43 | # Stable Diffusion requirements
44 | >>> RUN apt-get install -y libopencv-dev &&
45 | >>> ln -s /usr/include/opencv4/opencv2 /usr/include/opencv2
46 |
——————–
ERROR: failed to solve: process “/bin/sh -c apt-get install -y libopencv-dev && ln -s /usr/include/opencv4/opencv2 /usr/include/opencv2” did not complete successfully: exit code: 100
The error you encountered during the Docker image build is indicating that the process for installing the package `libopencv-dev` and creating a symbolic link did not complete successfully. The exit code 100 generally indicates a package installation error.
Let’s try to troubleshoot the issue:
1. **Verify Dependencies**: Ensure that you have the necessary dependencies and setup to install packages using `apt-get`. Sometimes, this error can occur if there are issues with the package repositories or if there are conflicting dependencies.
2. **Check Internet Connectivity**: Ensure that your Docker build environment has internet connectivity, as `apt-get` requires internet access to download and install packages.
3. **Update Package Lists**: Before installing packages, it’s a good practice to update the package lists to make sure you are getting the latest versions. Add the following line at the beginning of your Dockerfile:
“`Dockerfile
RUN apt-get update
“`
4. **Try Running Commands Separately**: Split the `apt-get install` and `ln` commands into separate `RUN` instructions in your Dockerfile. This can help you isolate the specific step causing the issue and provide more detailed error messages.
“`Dockerfile
# Stable Diffusion requirements
RUN apt-get update && apt-get install -y libopencv-dev
RUN ln -s /usr/include/opencv4/opencv2 /usr/include/opencv2
“`
5. **Use `apt` Instead of `apt-get`**: Sometimes, using `apt` instead of `apt-get` can resolve package installation issues. Update the relevant lines in your Dockerfile accordingly:
“`Dockerfile
# Stable Diffusion requirements
RUN apt update && apt install -y libopencv-dev
RUN ln -s /usr/include/opencv4/opencv2 /usr/include/opencv2
“`
6. **Check Dockerfile Context**: Ensure that the context provided for building the Docker image includes all the required files and dependencies. The context is the directory passed to the `docker build` command (e.g., `docker build -t localai .`). Verify that the necessary files are present in the directory where you are running the build command.
After trying these steps, attempt to build the Docker image again and see if the issue is resolved. If you encounter any specific error messages or issues, please provide them, and I’ll be happy to help further.
hoe to edit the bashrc file?
To edit the `bashrc` file, you can use a text editor of your choice. The `bashrc` file is a script that runs whenever you start a new interactive Bash shell. It allows you to customize your shell environment by setting environment variables, defining aliases, and adding other configurations.
Here are the general steps to edit the `bashrc` file:
1. **Open the Terminal**: Open a terminal or command prompt on your system. The steps for opening a terminal vary depending on your operating system:
– On Linux: You can usually find the terminal in the applications menu or use the keyboard shortcut `Ctrl + Alt + T`.
– On macOS: Open “Terminal” from the “Utilities” folder within the “Applications” folder.
– On Windows: You can use “Command Prompt” or “Windows Terminal.”
2. **Locate the bashrc File**: The `bashrc` file is typically located in your home directory. It is a hidden file, so its name starts with a dot (e.g., `.bashrc`). Use the following command to navigate to your home directory:
“`bash
cd ~
“`
3. **Edit the bashrc File**: Once you are in your home directory, use a text editor (e.g., nano, vim, or VSCode) to edit the `bashrc` file. For example, using nano:
“`bash
nano .bashrc
“`
This will open the `bashrc` file in the nano text editor, allowing you to make changes.
4. **Make Changes**: Scroll through the file and make any desired changes or additions to the configurations. For example, you can add environment variables, aliases, or custom commands.
5. **Save Changes**: After making your changes, save the file:
– In nano, press `Ctrl + O` (Write Out) and then `Enter` to save the changes.
– In vim, type `:wq` and press `Enter` to save and quit.
6. **Reload the bashrc File**: The changes you made in the `bashrc` file will only take effect in new terminal sessions. To apply the changes immediately in the current terminal session, you can either restart the terminal or run the following command:
“`bash
source ~/.bashrc
“`
This command reloads the `bashrc` file in the current shell session.
Remember to be careful when editing configuration files like `bashrc`, as incorrect changes can potentially cause issues with your shell environment. Always back up the file before making significant changes if you are unsure about the modifications you’re making.
drtripper@DESKTOP-UNG8TH9:~
It seems that you provided the command prompt of your terminal, which indicates that you are currently logged in as the user “drtripper” on the machine with the hostname “DESKTOP-UNG8TH9″. The `~` symbol at the end of the command prompt represents the current working directory, which is typically the user’s home directory.
If you have a specific question or task you’d like to perform, please feel free to let me know, and I’ll be happy to assist you further!
export PATH=”/home/drtripper/.local/bin:$PATH”
The command you provided is an example of an “export” command used to modify the PATH environment variable. The PATH variable is a list of directories that the shell uses to search for executable files when you enter a command in the terminal. By adding a directory to the PATH, you make it easier to run executable files located in that directory without having to provide the full path each time.
Here’s what the command does:
“`bash
export PATH=”/home/drtripper/.local/bin:$PATH”
“`
– `export`: This keyword is used to set an environment variable so that it is available to child processes launched from the current shell session.
– `PATH=”/home/drtripper/.local/bin:$PATH”`: This is the assignment part of the command. It sets the PATH environment variable to include the directory `/home/drtripper/.local/bin` followed by the existing value of the PATH variable (`$PATH`).
– `/home/drtripper/.local/bin`: This is the directory that is being added to the PATH. Any executable files located in this directory can now be run directly from the command line.
– `$PATH`: This is a special shell variable that holds the current value of the PATH. By appending `:$PATH`, you are instructing the shell to add the new directory to the beginning of the existing PATH, so it takes precedence over other directories in the list.
After running this command, the directory `/home/drtripper/.local/bin` will be included in the PATH for the current shell session. This means that any executable files located in that directory can be executed by typing their names directly in the terminal, without needing to specify the full path.
Keep in mind that this change is only valid for the current terminal session. If you want to make this change persistent and have it apply to all future terminal sessions, you should add this export command to your `~/.bashrc` or `~/.bash_profile` file (depending on your shell setup). This way, the PATH modification will be applied each time you start a new terminal session.
where is this in windows?
In Windows, the process for modifying the PATH environment variable is slightly different from Linux or macOS. Windows uses a graphical user interface (GUI) for system settings and environment variables. Here’s how you can modify the PATH environment variable in Windows:
1. **Open System Properties**:
– Right-click on the “This PC” or “My Computer” icon on your desktop or File Explorer.
– Select “Properties.”

2. **Open Advanced System Settings**:
– In the System window, click on the “Advanced system settings” link on the left side.

3. **Environment Variables**:
– In the System Properties dialog box, click the “Environment Variables…” button at the bottom.

4. **Edit the PATH Variable**:
– In the Environment Variables window, you’ll see two sections: User variables (for the currently logged-in user) and System variables (for all users on the system). Usually, you’ll want to modify the User variable to apply the change only to your user account.
– Under the “User variables” section, find the “Path” variable and select it.
– Click the “Edit” button to modify the PATH variable.

5. **Add New Directory**:
– In the “Edit Environment Variable” window, click the “New” button.
– Enter the path of the directory you want to add to the PATH. For example, `C:UsersYourUsernameAppDataLocalProgramsPythonPython39Scripts` if you want to add a Python scripts directory.
– Click “OK” to save the new path.

6. **Save Changes**:
– After adding the new directory, click “OK” in all open windows to save the changes.
7. **Restart or Start New Command Prompt**:
– To apply the changes, you’ll need to restart any open command prompt or PowerShell windows. Alternatively, you can open a new command prompt or PowerShell window to see the updated PATH variable.
The changes you made to the PATH environment variable will now be in effect, allowing you to run executables located in the added directory from any command prompt or PowerShell window without specifying the full path.
where do I find this path in the windows exploer: export PATH=”/home/drtripper/.local/bin:$PATH”
In the Windows Explorer, the equivalent path to `/home/drtripper/.local/bin` in your Linux command would be a location within your Windows user’s profile. However, Windows uses a different notation for paths compared to Linux.
The specific path you want to find or modify depends on your Python installation. Based on the provided command, it appears that you are trying to add the directory where Python executables are installed (`/home/drtripper/.local/bin`) to the PATH environment variable.
In Windows, the PATH environment variable is a semicolon-separated list of directories. Each directory in the PATH is searched for executable files when you run a command in the command prompt or PowerShell.
The equivalent path to `/home/drtripper/.local/bin` on Windows would typically be something like:
“`
C:UsersdrtripperAppDataLocalProgramsPythonPythonXXScripts
“`
Replace `drtripper` with your Windows username and `PythonXX` with the specific version of Python you have installed. For example, if you have Python 3.9 installed, the path might look like:
“`
C:UsersdrtripperAppDataLocalProgramsPythonPython39Scripts
“`
To add this path to the PATH environment variable in Windows:
1. Open the Windows Explorer and navigate to `C:UsersYourUsernameAppDataLocalProgramsPythonPythonXXScripts`, where `YourUsername` is your Windows username and `PythonXX` is the version of Python you have installed.
2. Copy the path from the address bar in Windows Explorer.
3. Follow the steps I provided earlier to modify the PATH environment variable (Control Panel > System > Advanced system settings > Environment Variables > Edit the “Path” variable > Add the copied path).
4. Save the changes and restart any open command prompt or PowerShell windows for the changes to take effect.
Once the path is added to the PATH environment variable, you can run Python scripts and executables located in the specified directory directly from the command prompt or PowerShell without specifying the full path.
I am usin wsl
Thank you for letting me know that you are using Windows Subsystem for Linux (WSL). In that case, the path you mentioned in the Linux command `/home/drtripper/.local/bin` is specific to your WSL Linux user’s home directory.
In WSL, your Windows user profile is automatically mounted and accessible under `/mnt/c` (for the C drive) or `/mnt/d` (for the D drive), and so on. Therefore, the path you need in Windows Explorer to locate the equivalent location is:
“`
C:UsersYourUsername.localbin
“`
Replace `YourUsername` with your Windows username.
To access this location from Windows Explorer:
1. Open Windows Explorer.
2. Navigate to `C:UsersYourUsername.localbin`, where `YourUsername` is your Windows username.
Here, you’ll find the equivalent location to the Linux path you provided. This is the directory where any executables or scripts installed within your WSL Linux user’s `.local/bin` would be located. Note that since this directory is part of your WSL environment, you won’t typically interact with it from native Windows applications.
If you need to modify the PATH within WSL (Linux environment), you should do that from within WSL using a Linux text editor like `nano` or `vim`, and the modifications would be specific to your WSL Linux user’s environment. To do so, open a WSL terminal and edit your `.bashrc` or `.bash_profile` (if it exists) to add the desired PATH modifications, similar to the Linux command you provided:
“`bash
export PATH=”$HOME/.local/bin:$PATH”
“`
After saving the changes to your `.bashrc` or `.bash_profile` file, you can either open a new terminal or run `source ~/.bashrc` or `source ~/.bash_profile` to apply the changes to the current terminal session.
I would like to be part of the path for the wsl
I would like to be part of the path for the wsl:: D:SuperAGi
Sure! To add a directory to the PATH specifically within your WSL environment, you need to modify the `.bashrc` file or `.bash_profile` file (if it exists) within WSL.
Here’s how you can do it:
1. Open your WSL terminal.
2. Use a text editor (e.g., `nano`, `vim`, or `code`) to edit your `.bashrc` file or create it if it doesn’t exist. Let’s use `nano` as an example:
“`bash
nano ~/.bashrc
“`
3. Add the following line at the end of the `.bashrc` file:
“`bash
export PATH=”$HOME/.local/bin:$PATH”
“`
This line appends the directory `~/.local/bin` (which is equivalent to `/home/yourusername/.local/bin` in WSL) to the existing PATH, making it part of the search path for executables.
Replace `yourusername` with your actual WSL Linux username.
4. Save the changes in `nano` by pressing `Ctrl + O`, then press `Enter`. To exit `nano`, press `Ctrl + X`.
5. Now, to apply the changes to the current terminal session, run the following command:
“`bash
source ~/.bashrc
“`
This will reload the `.bashrc` file in the current session, and the updated PATH will take effect.
6. You can verify that the directory has been added to the PATH by running:
“`bash
echo $PATH
“`
The output should show the directory `~/.local/bin` at the beginning of the PATH.
With these steps, you’ve successfully added `~/.local/bin` (or `/home/yourusername/.local/bin` in WSL) to your PATH within the WSL environment. Now, any executables installed in this directory will be accessible from the command line without specifying the full path.
To add a Windows path (`D:SuperAGi`) to the PATH environment variable within WSL, you can follow these steps:
1. **Identify WSL User’s Home Directory**: First, open a WSL terminal, and navigate to your WSL user’s home directory. By default, your WSL user’s home directory is usually located at `/home/your_username`, where `your_username` is your WSL username. You can use the following command to navigate there:
“`bash
cd ~
“`
2. **Edit `.bashrc` or `.bash_profile`**: In WSL, you can use a Linux text editor like `nano` or `vim` to edit your `.bashrc` or `.bash_profile` file. You can choose one of the following commands based on your preference (if you don’t have either file, you can create one):
Using nano:
“`bash
nano .bashrc
“`
Using vim:
“`bash
vim .bashrc
“`
3. **Add Path to `.bashrc` or `.bash_profile`**: In the opened text editor, add the following line at the end of the file to append `D:SuperAGi` to the PATH:
“`bash
export PATH=”/mnt/d/SuperAGi:$PATH”
“`
Save the changes and exit the text editor.
4. **Apply Changes**: After saving the changes, you can either open a new terminal or run the following command in the existing terminal to apply the changes to the current session:
“`bash
source .bashrc
“`
or
“`bash
source .bash_profile
“`
Now, the path `D:SuperAGi` should be added to your WSL’s PATH environment variable, and you can access the contents of `D:SuperAGi` directly from the WSL terminal without providing the full path. For example, you can run commands and scripts located in `D:SuperAGi` directly from WSL.
=> ERROR [requirements 11/12] RUN if echo “stablediffusion tts” | grep -q “tts”; then RUN test -n “amd64” || (echo ‘warn: missing $TARGETARCH, either set this `ARG` manually, or run using `d 0.5s
——
> [requirements 11/12] RUN if echo “stablediffusion tts” | grep -q “tts”; then RUN test -n “amd64” || (echo ‘warn: missing $TARGETARCH, either set this `ARG` manually, or run using `docker buildkit`’):
0.488 /bin/sh: 1: Syntax error: end of file unexpected (expecting “fi”)
——
Dockerfile:53
——————–
52 | # Use pre-compiled Piper phonemization library (includes onnxruntime)
53 | >>> RUN if echo “${GO_TAGS}” | grep -q “tts”; then
54 | >>> RUN test -n “$TARGETARCH”
55 | >>> || (echo ‘warn: missing $TARGETARCH, either set this `ARG` manually, or run using `docker buildkit`’)
56 |
——————–
ERROR: failed to solve: process “/bin/sh -c if echo “${GO_TAGS}” | grep -q “tts”; then RUN test -n “$TARGETARCH” || (echo ‘warn: missing $TARGETARCH, either set this `ARG` manually, or run using `docker buildkit`’)” did not complete successfully: exit code: 2
(base) gemini@DESKTOP-UNG8TH9:/mnt/d/SuperAGi/localai$
The error you are encountering in the Docker build log is related to the syntax used in the Dockerfile. It appears that the use of multiple `RUN` commands within an `if` statement is causing the issue.
To fix this, you need to combine the multiple `RUN` commands inside the `if` statement into a single `RUN` command. The correct syntax for a multi-line `RUN` command in Dockerfile is to use backslashes (“) at the end of each line to indicate continuation.
Let’s update the problematic lines in your Dockerfile accordingly:
“`Dockerfile
# Before:
RUN if echo “${GO_TAGS}” | grep -q “tts”; then
RUN test -n “$TARGETARCH”
|| (echo ‘warn: missing $TARGETARCH, either set this `ARG` manually, or run using `docker buildkit`’);
fi
# After:
RUN if echo “${GO_TAGS}” | grep -q “tts”; then
test -n “$TARGETARCH”
|| (echo ‘warn: missing $TARGETARCH, either set this `ARG` manually, or run using `docker buildkit`’);
fi
“`
The updated code combines the two `RUN` commands inside the `if` statement and uses backslashes (“) to indicate continuation of the command across multiple lines.
After making this change, try building the Docker image again:
“`bash
docker buildx -t localai .
“`
This should resolve the syntax error you encountered during the build process. If you encounter any other issues or errors, please provide additional details, and I’ll be happy to assist further.
ERR error loading config files: open /build/models: no such file or directory
The error message “ERR error loading config files: open /build/models: no such file or directory” typically indicates that Docker cannot find a file or directory specified in the Dockerfile or in the build context during the build process.
To troubleshoot this issue, follow these steps:
1. **Check Dockerfile**: Review your Dockerfile and ensure that there are no typos or incorrect paths specified in the commands. Pay attention to any `COPY`, `ADD`, or other file-related commands that reference the path `/build/models`.
2. **Check Build Context**: The build context is the directory containing the Dockerfile and any files that need to be copied into the image during the build. When you run the `docker build` command, it uses the current directory as the build context by default. Make sure that the required files or directories, including `/build/models`, are present within the build context. If the files are located elsewhere, you’ll need to adjust the build context or use the appropriate relative paths in your Dockerfile.
3. **Use Absolute Paths**: Instead of using relative paths in your Dockerfile, consider using absolute paths to ensure that Docker can locate the required files consistently, regardless of the build context. For example, if you are trying to copy files from the `/build/models` directory, use an absolute path like `/path/to/your/models:/build/models` in your `COPY` or `ADD` commands.
4. **Check File Permissions**: Ensure that the files and directories required during the build process have the necessary read permissions for Docker. If the files are located in a restricted directory, Docker may not be able to access them during the build.
5. **Build Command**: Double-check the exact `docker build` command you are running, and ensure that you are specifying the correct path to the build context. For example:
“`bash
docker build -t localai /path/to/build/context
“`
6. **Debugging**: If the issue persists and you are unsure which specific command is causing the problem, you can try adding `ls` or `pwd` commands to your Dockerfile at relevant points to check the contents of the directories or print the current working directory during the build process.
7. **Update Docker**: Ensure that you are using the latest version of Docker. If you are using an older version, consider upgrading to the latest stable release, as newer versions may have bug fixes and improvements.
By carefully checking your Dockerfile, build context, and paths used in the `COPY` or `ADD` commands, you should be able to resolve the “no such file or directory” error and successfully build your Docker image. If you encounter any specific issues or need further assistance, please provide more details about your Dockerfile and build setup.
version: ‘3.6’
services:
api:
image: quay.io/go-skynet/local-ai:latest
build:
context: ../../
dockerfile: Dockerfile
ports:
– 8080:8080
env_file:
– ../../.env
volumes:
– ./models:/models:cached
command: [“/usr/bin/local-ai”]
The provided `docker-compose.yml` file defines a Docker Compose configuration for a service named “api” that runs a container based on the “quay.io/go-skynet/local-ai:latest” image. This configuration includes various settings such as building the image, defining ports, environment variables, and volumes.
Let’s break down each part of the `docker-compose.yml` file:
“`yaml
version: ‘3.6’
services:
api:
image: quay.io/go-skynet/local-ai:latest
build:
context: ../../
dockerfile: Dockerfile
ports:
– 8080:8080
env_file:
– ../../.env
volumes:
– ./models:/models:cached
command: [“/usr/bin/local-ai”]
“`
1. **Version**: The `version` key specifies the version of the Docker Compose file format being used. In this case, it’s version 3.6.
2. **Services**: The `services` section defines the services (containers) to be run as part of the Docker Compose configuration. In this case, there’s one service named “api”.
3. **Image**: The `image` key specifies the Docker image to be used for the “api” service. It will use the pre-built image from the “quay.io/go-skynet/local-ai” repository with the “latest” tag.
4. **Build**: The `build` section is used when you want to build a custom image for the service. It specifies the build context and Dockerfile to use. The build context is set to “../../” (relative to the location of the `docker-compose.yml` file) and the Dockerfile is set to “Dockerfile”.
5. **Ports**: The `ports` key defines the port mapping between the host and the container. In this case, it maps port 8080 from the host to port 8080 in the container.
6. **Env_file**: The `env_file` key specifies the path to the file containing environment variables. It references a file named “.env” located at “../../” (relative to the location of the `docker-compose.yml` file).
7. **Volumes**: The `volumes` key defines the volumes to be mounted inside the container. It mounts the local “./models” directory to “/models” in the container. The “:cached” option is used to improve performance when using macOS.
8. **Command**: The `command` key specifies the command to be executed when starting the container. In this case, it runs “/usr/bin/local-ai” within the container.
The provided `docker-compose.yml` file appears to be a configuration for running the “api” service using the “quay.io/go-skynet/local-ai:latest” image, with specific ports, environment variables, volumes, and command options.
To use this `docker-compose.yml` file, you can run the following command in the directory containing the file:
“`bash
docker-compose up
“`
This will start the “api” service based on the configuration specified in the file.
i8 have no bin file at that location
If you don’t have a `bin` directory at the specified location or if you are encountering issues with the provided `docker-compose.yml` file, there are a few things you can check and adjust in the configuration:
1. **Verify Build Context**: The `build` section in the `docker-compose.yml` file references the build context and Dockerfile to use. Make sure the build context is correctly pointing to the directory that contains your Dockerfile. Also, ensure that the Dockerfile exists in that directory.
For example, if your Dockerfile is in the same directory as the `docker-compose.yml` file, you should use:
“`yaml
build:
context: .
dockerfile: Dockerfile
“`
2. **Verify Image Availability**: If you don’t have a local `Dockerfile` or build context, the `docker-compose.yml` file uses the image `quay.io/go-skynet/local-ai:latest`. Ensure that this image exists and is publicly available. If it is a private image, you might need to log in to the registry (`quay.io` in this case) using `docker login` before running `docker-compose`.
3. **Check Volume Mount**: The `volumes` section in the `docker-compose.yml` file is mounting the `./models` directory to `/models` inside the container. Ensure that the `./models` directory exists and contains the necessary files. If it doesn’t exist, create it before running `docker-compose`.
4. **Verify Command**: The `command` section specifies the command to be executed inside the container. In this case, it is running “/usr/bin/local-ai”. Make sure this command exists and is available in the image you are using.
5. **Debugging**: If the issue persists, you can try adding `ls` or `pwd` commands in the Dockerfile to check the contents of directories and the current working directory during the build process or container execution. This can help you identify any discrepancies in the paths or directories.
6. **Permissions**: Ensure that you have the necessary permissions to access the files and directories involved. On Linux, file permissions might play a role in accessing the `models` directory.
After making any necessary adjustments, try running `docker-compose up` again. If there are any specific error messages you encounter, please provide them, and I’ll be glad to assist you further.
this is the parent dockerfile:: version: ‘3.6’
services:
api:
image: quay.io/go-skynet/local-ai:latest
build:
context: .
dockerfile: Dockerfile
ports:
– 8080:8080
env_file:
– .env
volumes:
– ./models:/models:cached
command: [“/usr/bin/local-ai” ]
Thank you for providing the parent `docker-compose.yml` file. Based on the configuration you shared, it appears to be correctly referencing the local context and Dockerfile for building the Docker image for the “api” service. The build context is set to the current directory (denoted by `.`), and the `Dockerfile` is located in the same directory as the `docker-compose.yml` file.
The `volumes` section specifies that the `./models` directory on the host machine (relative to the location of the `docker-compose.yml` file) should be mounted inside the container at `/models`. This allows you to share data between the host and the container. Make sure that the `./models` directory exists in the same location as the `docker-compose.yml` file and contains the necessary files for the application.
The `command` section specifies the command to be executed inside the container. In this case, it runs `/usr/bin/local-ai`. Ensure that the command exists and is available in the image you are using.
To run the service defined in the `docker-compose.yml` file, execute the following command in the directory containing the `docker-compose.yml` file:
“`bash
docker-compose up
“`
This command will build the Docker image using the specified `Dockerfile` and configuration, and then run the “api” service based on the settings in the `docker-compose.yml` file.
If you encounter any specific error messages or issues during the build or run process, please provide them, and I’ll be happy to help you troubleshoot further.
usr/bin/local-ai”
It appears that the provided command in the `command` section of the `docker-compose.yml` file is `/usr/bin/local-ai`. This command is expected to be executed inside the container when the container starts.
If `/usr/bin/local-ai` is indeed the correct command that needs to be executed within the container, make sure that the image `quay.io/go-skynet/local-ai:latest` (used in the `image` section of the `docker-compose.yml` file) contains the `/usr/bin/local-ai` executable.
Here are a few steps you can take to verify the existence of the `/usr/bin/local-ai` executable:
1. **Check Docker Image Contents**: To inspect the contents of the Docker image, you can use the following command to run a shell inside the container:
“`bash
docker run -it quay.io/go-skynet/local-ai:latest /bin/sh
“`
This command will start a shell session inside the container. Once inside, you can check whether the `/usr/bin/local-ai` executable exists by running:
“`bash
ls /usr/bin/local-ai
“`
If the executable is present, it will be listed in the output. If it’s not present, you may need to investigate the image’s contents or the build process that created it.
2. **Review Dockerfile**: If you have access to the Dockerfile used to build the image `quay.io/go-skynet/local-ai:latest`, review its contents to ensure that the `/usr/bin/local-ai` executable is properly installed or copied into the image during the build process.
3. **Check with the Image Maintainer**: If you did not create the Docker image yourself and it is maintained by someone else or a public registry (e.g., quay.io), consider checking the image’s documentation or contacting the maintainer to inquire about the availability of the `/usr/bin/local-ai` executable.
4. **Use Different Command**: If the `/usr/bin/local-ai` command is not available in the image, you might need to use a different command that is available or compatible with the image. You can specify a different command in the `command` section of the `docker-compose.yml` file.
Remember that the command specified in the `command` section will be executed within the container at runtime, and it should be a valid executable or script available in the container’s filesystem. If the command is missing or incorrect, the container may fail to start or behave unexpectedly.
If you encounter specific errors or issues while trying to run the container, please provide the error messages, and I’ll be happy to assist you further in troubleshooting.
Wher is this locatd? usr/bin/local-ai”
The path `/usr/bin/local-ai` refers to a location within the filesystem of the Docker container, not on your host machine. It is not a path in your local file system, but rather a path within the container’s file system.
When you run a Docker container, it creates an isolated environment with its own filesystem separate from the host machine’s filesystem. The paths inside the container are independent of the paths on your host machine.
To locate the `/usr/bin/local-ai` executable within the Docker container, you can use the `docker run` command to start an interactive shell session inside the container. This will allow you to explore the container’s filesystem and check if the executable exists.
Here’s the command to run a shell inside the container:
“`bash
docker run -it quay.io/go-skynet/local-ai:latest /bin/sh
“`
This command will start an interactive shell session inside the container based on the `quay.io/go-skynet/local-ai:latest` image. Once inside the container, you can check the existence of `/usr/bin/local-ai` by running:
“`bash
ls /usr/bin/local-ai
“`
If the `/usr/bin/local-ai` executable is present in the container, it will be listed in the output. If it’s not present, you might need to investigate the container’s contents or the build process used to create the image.
Keep in mind that changes made inside the container during this interactive shell session will not affect the image itself. It is only for exploration and debugging purposes.
Remember, Docker images are pre-packaged environments, and the availability of specific files or executables within the image depends on how the image was built. If you are not the creator of the image, you may need to consult the image’s documentation or contact the maintainer for information about the `/usr/bin/local-ai` executable.
docker run -it quay.io/go-skynet/local-ai:latest /bin/sh
@@@@@
Skipping rebuild
@@@@@
If you are experiencing issues with the pre-compiled builds, try setting REBUILD=true
If you are still experiencing issues with the build, try setting CMAKE_ARGS and disable the instructions set as needed:
CMAKE_ARGS=”-DLLAMA_F16C=OFF -DLLAMA_AVX512=OFF -DLLAMA_AVX2=OFF -DLLAMA_FMA=OFF”
see the documentation at: https://localai.io/basics/build/index.html
Note: See also https://github.com/go-skynet/LocalAI/issues/288
@@@@@
CPU info:
model name : AMD Ryzen 9 5900X 12-Core Processor
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl tsc_reliable nonstop_tsc cpuid extd_apicid pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm cmp_legacy cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw topoext ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 erms rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves clzero xsaveerptr arat umip vaes vpclmulqdq rdpid fsrm
CPU: AVX found OK
CPU: AVX2 found OK
CPU: no AVX512 found
@@@@@
1:13PM DBG no galleries to load
1:13PM INF Starting LocalAI using 4 threads, with models path: /build/models
1:13PM INF LocalAI version: v1.23.0 (688f1504636810bbe40cffa2c88fe78f0ff09dc9)
1:13PM ERR error loading config files: open /build/models: no such file or directory
Based on the output you provided, it seems that the container successfully started, and the application inside the container is running. However, the application encountered an error while attempting to load configuration files from the `/build/models` directory, which does not exist inside the container.
The specific error message is:
“`
ERR error loading config files: open /build/models: no such file or directory
“`
Here are some steps you can take to troubleshoot the issue:
1. **Verify File Paths**: Double-check the paths used in the application’s configuration to ensure that they are correct. The application is looking for configuration files in the `/build/models` directory, so make sure that this directory exists and contains the necessary configuration files. If the path is incorrect, you may need to adjust the configuration to use the correct path within the container.
2. **Volume Mount**: In your `docker-compose.yml`, you are mounting the `./models` directory on the host machine to `/models` inside the container. However, it seems that the application is expecting the configuration files in the `/build/models` directory. Make sure the volume mount is correctly set in the `docker-compose.yml` file.
For example, if your configuration expects the files in `/build/models`, you should update the `volumes` section in the `docker-compose.yml` file as follows:
“`yaml
volumes:
– ./models:/build/models:cached
“`
This will mount the `./models` directory on the host to `/build/models` inside the container.
3. **Check Application Documentation**: Review the documentation for the application you are running (`LocalAI`). It may provide guidance on how to configure the application correctly and where it expects the configuration files to be located.
4. **Rebuild with CMAKE_ARGS**: As mentioned in the output, if you are still experiencing issues with the build, you can try setting `CMAKE_ARGS` when building the image. For example:
“`bash
docker build -t quay.io/go-skynet/local-ai:latest –build-arg CMAKE_ARGS=”-DLLAMA_F16C=OFF -DLLAMA_AVX512=OFF -DLLAMA_AVX2=OFF -DLLAMA_FMA=OFF” .
“`
This command will build the image with specific CMake arguments. However, this may not be directly related to the issue of missing configuration files.
5. **Check GitHub Issue**: The output also references a GitHub issue related to the problem. You can check the issue on GitHub (https://github.com/go-skynet/LocalAI/issues/288) to see if there are any insights or solutions provided by the project’s maintainers.
Remember that the error is specific to the application running inside the container and its configuration. Check the application’s documentation and verify the paths and volume mounts to resolve the issue with loading configuration files. If you require further assistance, don’t hesitate to provide additional details or error messages for more focused support.
is there a wau to just point to the right location in the launch?
Yes, you can modify the launch command in the `docker-compose.yml` file to point to the correct location for the configuration files within the container. To do this, you need to adjust the `command` section in the `docker-compose.yml` file.
Based on the provided output and assuming that the application inside the container is expecting configuration files in the `/build/models` directory, you can update the `command` section like this:
“`yaml
version: ‘3.6’
services:
api:
image: quay.io/go-skynet/local-ai:latest
build:
context: .
dockerfile: Dockerfile
ports:
– 8080:8080
env_file:
– .env
volumes:
– ./models:/build/models:cached
command: [“/usr/bin/local-ai”, “–models”, “/build/models”]
“`
In this modification, we’ve appended `–models /build/models` to the `command` list. This passes the flag `–models /build/models` to the `local-ai` executable, indicating that the configuration files are located in the `/build/models` directory inside the container.
Remember to use the appropriate location according to your application’s expectations. If the configuration files are expected in a different directory, adjust the `–models` flag accordingly.
After making this change, you can run the `docker-compose` command again:
“`bash
docker-compose up
“`
This will start the container with the updated command that points to the correct location for the configuration files. If the application’s configuration is set up correctly, it should be able to locate and load the configuration files without any errors.
Always ensure to refer to the application’s documentation or the project’s maintainers if you’re uncertain about the correct configurations and paths.
Dockerfile:44
——————–
43 | # Stable Diffusion requirements
44 | >>> RUN apt-get install -y libopencv-dev &&
45 | >>> ln -s /usr/include/opencv4/opencv2 /usr/include/opencv2
46 |
——————–
ERROR: failed to solve: process “/bin/sh -c apt-get install -y libopencv-dev && ln -s /usr/include/opencv4/opencv2 /usr/include/opencv2” did not complete successfully: exit code: 100
The error you encountered during the Docker build process indicates that the `RUN` command in the Dockerfile failed to execute successfully. Specifically, the issue seems to be related to the installation of the `libopencv-dev` package and creating a symbolic link (`ln -s`) for OpenCV header files.
Here are some possible reasons and troubleshooting steps to address the problem:
1. **Check Internet Connectivity**: Ensure that your Docker build environment has internet connectivity to download packages. A lack of internet connectivity could prevent the `apt-get` command from retrieving the required packages.
2. **Package Availability**: Verify that the `libopencv-dev` package is available in the package repository. The package might be missing or unavailable in the repository you are using.
3. **Update Package Lists**: Try running an `apt-get update` command before installing the packages to ensure that the package lists are up to date.
4. **Different Package Manager**: If you are using a non-Debian-based base image (e.g., CentOS, Alpine), the package manager might be different. Make sure to use the appropriate package manager and package name for the specific base image.
5. **Check Exit Code 100**: The exit code 100 indicates an error during the package installation process. Review the full output from the `apt-get install` command for any error messages or additional information that might help identify the problem.
6. **Debugging in the Container**: If the issue persists, you can try building the Docker image interactively to debug the problem further. Use the `docker run -it /bin/bash` command to start a shell inside the container. Then, manually run the `apt-get install` command and observe any errors or messages.
7. **Dockerfile Cleanup**: If the problem persists, ensure that there are no conflicting or problematic instructions in the Dockerfile that might interfere with the installation process.
Based on the provided Dockerfile snippet, you can try the following adjustments:
“`Dockerfile
# Stable Diffusion requirements
RUN apt-get update && apt-get install -y libopencv-dev &&
ln -s /usr/include/opencv4/opencv2 /usr/include/opencv2
“`
The adjustments include running `apt-get update` before installing the package and combining the two commands into a single `RUN` instruction. This might help resolve any potential issues during the installation.
After making the adjustments, try rebuilding the Docker image:
“`bash
docker build -t localai .
“`
If you encounter specific error messages or issues during the build process, please provide more details, and I’ll be happy to assist you further in troubleshooting.
How about cut out stable diffusion until i can get a positive build
If you want to temporarily skip the installation of the “Stable Diffusion” requirements in the Dockerfile until you can get a successful build, you can comment out or remove the relevant lines from the Dockerfile. This way, the build process won’t attempt to install the problematic packages, and you can focus on other parts of the build that might be causing issues.
In the provided Dockerfile snippet, the “Stable Diffusion” requirements are located between lines 43 and 46. To skip this section, you can modify the Dockerfile like this:
“`Dockerfile
# … (Previous instructions above)
# Comment out the “Stable Diffusion” requirements
# RUN apt-get install -y libopencv-dev &&
# ln -s /usr/include/opencv4/opencv2 /usr/include/opencv2
# … (Remaining instructions below)
“`
By adding the `#` symbol at the beginning of the lines, you turn those lines into comments, effectively excluding them from the build process. This will prevent the installation of “libopencv-dev” and the creation of the symbolic link during the build.
After commenting out the problematic section, you can attempt to rebuild the Docker image using the modified Dockerfile:
“`bash
docker build -t localai .
“`
This should skip the “Stable Diffusion” requirements and allow you to see if the build is successful without those dependencies.
Remember that commenting out the “Stable Diffusion” requirements is a temporary measure to diagnose the build issue. Once you resolve the problem or obtain a positive build, you can revert the Dockerfile to include those requirements back in if they are essential for the functionality of the application.
If you encounter any other issues during the build or need further assistance, feel free to provide more details, and I’ll be glad to help you further.
sudo apt-get libopencv-dev
[sudo] password for drtripper:
E: Invalid operation libopencv-dev
It seems like there’s a small syntax error in the command you provided. The correct syntax to install the `libopencv-dev` package using `apt-get` is as follows:
“`bash
sudo apt-get install libopencv-dev
“`
In this command:
– `sudo`: It runs the command with administrative privileges, so you may need to enter your user password.
– `apt-get`: The package manager used in Ubuntu and Debian-based systems.
– `install`: The `apt-get` subcommand to install packages.
– `libopencv-dev`: The name of the package you want to install. `libopencv-dev` is the package that contains the development files and headers for OpenCV, which is useful for compiling software that uses OpenCV.
So, to install `libopencv-dev`, you can use the corrected command:
“`bash
sudo apt-get install libopencv-dev
“`
After installing the package, you should be able to proceed with your build process. If you encounter any other issues or have further questions, feel free to ask!
so libopencv-dev installs from the wsl command line
Yes, `libopencv-dev` can be installed from the WSL (Windows Subsystem for Linux) command line in the same way as you would install it in a native Ubuntu or Debian-based Linux environment. WSL provides a Linux-compatible environment on Windows, allowing you to run Linux commands and applications without the need for a virtual machine.
To install `libopencv-dev` using the WSL command line, follow these steps:
1. **Open WSL**: Launch your WSL terminal by opening the “Command Prompt” or “PowerShell” in Windows and running the desired WSL distribution (e.g., Ubuntu, Debian).
2. **Update Package Lists (Optional)**: It’s a good practice to update the package lists before installing new packages. You can do this with the following command:
“`bash
sudo apt-get update
“`
3. **Install libopencv-dev**: To install `libopencv-dev`, use the `apt-get` package manager as follows:
“`bash
sudo apt-get install libopencv-dev
“`
This will prompt you to confirm the installation and may require you to enter your user password (since you are using `sudo`).
4. **Proceed with the Build**: After successfully installing `libopencv-dev`, you can proceed with your Docker build or any other build process that requires the OpenCV development files.
Keep in mind that WSL provides a Linux environment running alongside Windows, so you can use standard Linux commands like `apt-get` to manage packages just as you would in a native Linux environment.
If you encounter any issues or need further assistance, please feel free to ask!
But it won’t run inscript?
If you are referring to running `apt-get install libopencv-dev` as part of a script within your Dockerfile, you might encounter issues. The reason is that Docker build processes do not have interactive prompts, and the `apt-get install` command may require user interaction to proceed with the installation.
To ensure that the package installation process does not require user input, you can use the `DEBIAN_FRONTEND` environment variable to set the package manager frontend to noninteractive. This will prevent any prompts during the package installation process.
Here’s how you can modify the Dockerfile to install `libopencv-dev` non-interactively:
“`Dockerfile
# Use the base image of your choice
FROM ubuntu:20.04
# Set the DEBIAN_FRONTEND environment variable to noninteractive
ENV DEBIAN_FRONTEND=noninteractive
# Update package lists and install necessary packages
RUN apt-get update && apt-get install -y libopencv-dev
# Continue with other instructions in your Dockerfile
“`
By setting `DEBIAN_FRONTEND=noninteractive`, you inform the package manager to avoid any prompts during the installation process, making it suitable for use in automated scripts and Docker builds.
Keep in mind that the `libopencv-dev` package installation might still generate some informational messages, but they should not require user interaction.
With this modification, the Docker build process should proceed without requiring any user input for package installations.
IN WSL?
Apologies for the confusion. Since you are running in WSL (Windows Subsystem for Linux), you don’t need to use `sudo` for package installations. In WSL, you are already in a Linux environment, and you have administrative privileges without using `sudo`.
To install packages in WSL, including `libopencv-dev`, you can simply use the `apt-get` command without `sudo`. Here’s the correct command to install `libopencv-dev` in WSL:
“`bash
sudo apt-get update
sudo apt-get install libopencv-dev
“`
In WSL, you should use `sudo` before `apt-get` since administrative privileges are required to perform package installations and updates.
Again, my apologies for the confusion in the previous response. You can follow the above commands to install `libopencv-dev` in WSL. Once installed, you can proceed with your Docker build process or any other development tasks that require OpenCV.
IN SCRIPT?
Apologies for the misunderstanding. If you want to include the package installation commands in a script within your Dockerfile, you can do so by using the `RUN` instruction. However, since you are running in WSL and not directly in a Linux environment, you won’t need `sudo` for package installations inside the Docker container.
Here’s an example of how you can include the package installation commands in a Dockerfile script:
“`Dockerfile
# Use the base image of your choice
FROM ubuntu:20.04
# Update package lists and install necessary packages
RUN apt-get update && apt-get install -y libopencv-dev
# Continue with other instructions in your Dockerfile
“`
In this Dockerfile, the `RUN` instruction is used to execute the `apt-get update` and `apt-get install` commands during the Docker build process. The `RUN` instruction allows you to include any commands you need to set up the environment and install dependencies within the Docker container.
Since you are running in WSL, you don’t need to use `sudo` in the Dockerfile script. The Docker build process will automatically run the commands as the root user inside the container, and administrative privileges are not required.
After creating or modifying your Dockerfile, you can build the Docker image using the `docker build` command:
“`bash
docker build -t your_image_name .
“`
Replace `your_image_name` with the desired name for your Docker image. The build process will execute the script in the Dockerfile and install `libopencv-dev` inside the container.
If you have any further questions or encounter any issues, feel free to ask for more help!
Dockerfile:58
——————–
57 |
58 | >>> RUN curl -L “https://github.com/gabime/spdlog/archive/refs/tags/v${SPDLOG_VERSION}.tar.gz” |
59 | >>> tar -xzvf – &&
60 | >>> mkdir -p “spdlog-${SPDLOG_VERSION}/build” &&
61 | >>> cd “spdlog-${SPDLOG_VERSION}/build” &&
62 | >>> cmake .. &&
63 | >>> make -j8 &&
64 | >>> cmake –install . –prefix /usr && mkdir -p “lib/Linux-$(uname -m)” &&
65 | >>> cd /build &&
66 | >>> mkdir -p “lib/Linux-$(uname -m)/piper_phonemize” &&
67 | >>> curl -L “https://github.com/rhasspy/piper-phonemize/releases/download/v${PIPER_PHONEMIZE_VERSION}/libpiper_phonemize-${TARGETARCH:-$(go env GOARCH)}${TARGETVARIANT}.tar.gz” |
68 | >>> tar -C “lib/Linux-$(uname -m)/piper_phonemize” -xzvf – && ls -liah /build/lib/Linux-$(uname -m)/piper_phonemize/ &&
69 | >>> cp -rfv /build/lib/Linux-$(uname -m)/piper_phonemize/lib/. /lib64/ &&
70 | >>> cp -rfv /build/lib/Linux-$(uname -m)/piper_phonemize/lib/. /usr/lib/ &&
71 | >>> cp -rfv /build/lib/Linux-$(uname -m)/piper_phonemize/include/. /usr/include/
72 | #
——————–
ERROR: failed to solve: process “/bin/sh -c curl -L “https://github.com/gabime/spdlog/archive/refs/tags/v${SPDLOG_VERSION}.tar.gz” | tar -xzvf – && mkdir -p “spdlog-${SPDLOG_VERSION}/build”
&& cd “spdlog-${SPDLOG_VERSION}/build” && cmake .. && make -j8 && cmake –install . –prefix /usr && mkdir -p “lib/Linux-$(uname -m)” && cd /build && mkdir -p “lib/Linux-$(uname -m)/piper_phonemize” && curl -L “https://github.com/rhasspy/piper-phonemize/releases/download/v${PIPER_PHONEMIZE_VERSION}/libpiper_phonemize-${TARGETARCH:-$(go env GOARCH)}${TARGETVARIANT}.tar.gz” | tar -C “lib/Linux-$(uname -m)/piper_phonemize” -xzvf – && ls -liah /build/lib/Linux-$(uname -m)/piper_phonemize/ && cp -rfv /build/lib/Linux-$(uname -m)/piper_phonemize/lib/. /lib64/ && cp -rfv /build/lib/Linux-$(uname -m)/piper_phonemize/lib/. /usr/lib/ && cp -rfv /build/lib/Linux-$(uname -m)/piper_phonemize/include/. /usr/include/” did not complete successfully: exit code: 2
The error you encountered during the Docker build process indicates that the `RUN` command in the Dockerfile failed to execute successfully. The error message does not provide specific details about the root cause, but it appears to be related to the commands that download and build the `spdlog` and `libpiper_phonemize` libraries.
To troubleshoot and identify the issue, you can try the following steps:
1. **Check Internet Connectivity**: Ensure that your Docker build environment has internet connectivity to download the required files from GitHub. If your environment is behind a firewall or proxy, it might prevent the `curl` command from accessing the URLs.
2. **Check GitHub URLs**: Verify that the URLs used in the `curl` commands to download the `spdlog` and `libpiper_phonemize` libraries are valid and accessible. You can test the URLs manually in your WSL terminal using `curl` to see if they download the correct files.
3. **Debug the Dockerfile**: To identify which command is causing the issue, you can break down the `RUN` command into multiple smaller commands. This way, you can run each step interactively in the Docker container to see where the failure occurs.
For example, you can start the container interactively using `docker run -it your_image_name /bin/bash`, then run each command from the `RUN` instruction one by one to check for errors.
4. **Docker Build Context**: Ensure that all the necessary files and dependencies required for the build are available within the Docker build context. The Docker build context includes the current directory and all its subdirectories. Make sure that any required files referenced in the Dockerfile are present and accessible.
5. **Check GitHub Repositories**: If the build is fetching specific versions from GitHub repositories, make sure that those versions exist and are accessible in the respective repositories. Version tags may have changed or been removed, which could lead to download failures.
6. **Verify Environment Variables**: Ensure that environment variables such as `${SPDLOG_VERSION}` and `${PIPER_PHONEMIZE_VERSION}` are correctly set to the desired versions of the libraries. Check if they match the versions you expect and are available on GitHub.
Once you’ve identified the specific step causing the failure, you can focus on troubleshooting that particular command or section of the Dockerfile.
If you encounter specific error messages or need further assistance, please provide more details or share the relevant portions of the Dockerfile, and I’ll be glad to help you further.
phonemize is for tts right?
Yes, you are correct. “Phonemize” is a term often used in the context of Text-to-Speech (TTS) systems. It refers to the process of converting text (words, sentences, or paragraphs) into phonemes, which are the basic units of speech sounds.
Phonemes are the smallest distinctive units of sound that can change the meaning of a word. TTS systems use phonemes to synthesize speech from text input. By converting text into phonemes, the TTS engine can accurately produce the corresponding speech sounds and create more natural and intelligible speech output.
In the error message you provided, it seems that the Dockerfile is attempting to fetch and install the `libpiper_phonemize` library, which is likely related to phonemization functionality used in a TTS system or related application.
The overall purpose of the Dockerfile and the `libpiper_phonemize` library may involve setting up a TTS-related environment or application that requires phonemization capabilities.
If you are working with TTS or related technologies, phonemization is a crucial step in the TTS pipeline, allowing the system to accurately generate speech sounds based on the input text.
ERROR: failed to solve: process “/bin/sh -c curl -L “https://github.com/gabime/spdlog/archive/refs/tags/v${SPDLOG_VERSION}.tar.gz” | tar -xzvf – && mkdir -p “spdlog-${SPDLOG_VERSION}/build”
&& cd “spdlog-${SPDLOG_VERSION}/build” && cmake .. && make -j8 && cmake –install . –prefix /usr && mkdir -p “lib/Linux-$(uname -m)” && cd /build && mkdir -p “lib/Linux-$(uname -m)/piper_phonemize” && curl -L “https://github.com/rhasspy/piper-phonemize/releases/download/v${PIPER_PHONEMIZE_VERSION}/libpiper_phonemize-${TARGETARCH:-$(go env GOARCH)}${TARGETVARIANT}.tar.gz” | tar -C “lib/Linux-$(uname -m)/piper_phonemize” -xzvf – && ls -liah /build/lib/Linux-$(uname -m)/piper_phonemize/ && cp -rfv /build/lib/Linux-$(uname -m)/piper_phonemize/lib/. /lib64/ && cp -rfv /build/lib/Linux-$(uname -m)/piper_phonemize/lib/. /usr/lib/ && cp -rfv /build/lib/Linux-$(uname -m)/piper_phonemize/include/. /usr/include/; fi” did not complete successfully: exit
code: 2
(GPTQ) gemini@DESKTOP-UNG8TH9:/mnt/d/SuperAGi/localai$ docker build -t local-ai .
The error you are encountering is a continuation of the previous issue with the Docker build process. The build process is failing during the execution of the long `RUN` command in the Dockerfile, which includes several commands for fetching and building the `spdlog` and `libpiper_phonemize` libraries.
As mentioned earlier, this kind of error message does not provide detailed information about the root cause of the failure. To troubleshoot the issue, you can break down the `RUN` command into smaller steps to identify the exact step where the build process fails. Additionally, running the build interactively can help you investigate further.
Here’s a modified version of the Dockerfile that splits the `RUN` command into separate steps for better debugging:
“`Dockerfile
# Use the base image of your choice
FROM ubuntu:20.04
# Set the DEBIAN_FRONTEND environment variable to noninteractive
ENV DEBIAN_FRONTEND=noninteractive
# Install required packages
RUN apt-get update && apt-get install -y libopencv-dev curl cmake make
# Install spdlog
ARG SPDLOG_VERSION=1.9.2
RUN curl -L “https://github.com/gabime/spdlog/archive/refs/tags/v${SPDLOG_VERSION}.tar.gz” | tar -xzvf – &&
mkdir -p “spdlog-${SPDLOG_VERSION}/build” &&
cd “spdlog-${SPDLOG_VERSION}/build” &&
cmake .. &&
make -j8 &&
cmake –install . –prefix /usr
# Install libpiper_phonemize
ARG PIPER_PHONEMIZE_VERSION=0.1.0
RUN mkdir -p “lib/Linux-$(uname -m)/piper_phonemize” &&
curl -L “https://github.com/rhasspy/piper-phonemize/releases/download/v${PIPER_PHONEMIZE_VERSION}/libpiper_phonemize-${TARGETARCH:-$(go env GOARCH)}${TARGETVARIANT}.tar.gz” | tar -C “lib/Linux-$(uname -m)/piper_phonemize” -xzvf – &&
ls -liah /build/lib/Linux-$(uname -m)/piper_phonemize/ &&
cp -rfv /build/lib/Linux-$(uname -m)/piper_phonemize/lib/. /lib64/ &&
cp -rfv /build/lib/Linux-$(uname -m)/piper_phonemize/lib/. /usr/lib/ &&
cp -rfv /build/lib/Linux-$(uname -m)/piper_phonemize/include/. /usr/include/
# Continue with other instructions in your Dockerfile
“`
With this modification, the Dockerfile separates the installation of `libopencv-dev` and other required packages from the `spdlog` and `libpiper_phonemize` installations. This way, you can better identify which step is causing the issue.
Please run the build process with the updated Dockerfile and observe the output for any errors or specific error messages that might help pinpoint the problem. If you encounter any specific issues, please share the relevant parts of the Docker build output for further assistance.
No, I am trying to root this tts out
Apologies for the confusion. It seems you are encountering issues specifically related to the TTS (Text-to-Speech) library or component called “piper-phonemize” during the Docker build process. Since “piper-phonemize” is part of the TTS functionality, let’s focus on troubleshooting that part of the build.
It’s important to note that the provided Dockerfile snippet does not include the values for `${PIPER_PHONEMIZE_VERSION}`, `${TARGETARCH}`, and `${TARGETVARIANT}`. These are likely environment variables or build arguments used to determine specific versions or configurations of “piper-phonemize.”
To better understand and resolve the issue, you can follow these steps:
1. **Verify Environment Variables**: Ensure that all the necessary environment variables or build arguments (`${PIPER_PHONEMIZE_VERSION}`, `${TARGETARCH}`, `${TARGETVARIANT}`) are correctly set to their desired values. You may need to set them in the Dockerfile or during the build command with `–build-arg` option.
2. **Check GitHub URL**: Double-check the GitHub URL used to fetch the “piper-phonemize” library. Verify that the URL is correct and accessible. If the URL has changed or the specific version/tag does not exist, it may result in a failure to fetch the library.
3. **Interactively Debug**: You can run the Docker build process interactively to debug the issue step by step. Use the `-it` flags with the `docker build` command to enter the container at a specific step. For example:
“`bash
docker build -t local-ai . –target step_name
docker run -it local-ai /bin/bash
“`
Replace `step_name` with the build stage name where “piper-phonemize” is being installed. This will allow you to explore the container environment and execute commands manually, observing any errors that might occur.
4. **Check Dependencies**: Ensure that any dependencies required by “piper-phonemize” are correctly installed in the container. It might depend on certain libraries or tools that are missing in the build environment.
5. **Check GitHub Repository**: Verify that the specific version of “piper-phonemize” corresponding to `${PIPER_PHONEMIZE_VERSION}` exists in the GitHub repository. If it’s a private repository, check for access permissions.
6. **Read Documentation**: Review the documentation of “piper-phonemize” to check if there are any additional build or installation requirements specific to that library.
7. **Community Support**: If the issue persists, you can seek help from the TTS library’s community or GitHub repository for support. They might have encountered similar build issues and can provide assistance.
Keep in mind that TTS systems can be complex, and the success of the build process often depends on the specific dependencies and configurations required for the application.
If you can provide more details about the error messages, the TTS library used, or the specific environment variables, I’d be happy to assist you further in resolving the issue.
=> ERROR [stage-2 5/5] COPY –from=builder /build/local-ai ./ 0.0s
——
> [stage-2 5/5] COPY –from=builder /build/local-ai ./:
——
Dockerfile:119
——————–
117 | COPY . .
118 | RUN make prepare-sources
119 | >>> COPY –from=builder /build/local-ai ./
120 |
121 | # Define the health check command
——————–
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref 46450627-0dae-4d32-bcbc-ad1a514ee96c::os5bvsq5569guteum33a65p2k: “/build/local-ai”: not found
The error you encountered during the Docker build process indicates that the specified source directory “/build/local-ai” from the “builder” stage is not found. This error typically occurs when the previous stage (builder stage) failed to create or produce the expected artifacts in the “/build/local-ai” directory, or when the build context is missing necessary files.
To troubleshoot this issue, you should first look at the “builder” stage and verify if it is correctly generating the “/build/local-ai” directory and the required files within it.
Here are some steps you can take to troubleshoot the issue:
1. **Check the “builder” Stage**: Examine the “builder” stage of your Dockerfile where the “/build/local-ai” directory is created. Ensure that this stage successfully completes without any errors. If there are errors in the “builder” stage, they might prevent the necessary files from being generated.
2. **Verify the Build Context**: Make sure that all the required files and directories are present in the build context. The build context includes the current directory and all its subdirectories. Any files that need to be copied during the build process should be available within the build context.
3. **Check Dockerignore**: Review the “.dockerignore” file (if present) in the build context. Ensure that it is not excluding any required files or directories that should be copied into the image.
4. **Interactive Debugging**: You can run the “builder” stage interactively to inspect its contents and verify if the “/build/local-ai” directory and expected files exist.
For example, you can build the “builder” stage and enter the container interactively to check the “/build” directory:
“`bash
docker build -t local-ai-builder -f Dockerfile.builder .
docker run -it local-ai-builder /bin/bash
“`
Inside the container, navigate to the “/build” directory and check if the “local-ai” directory exists and contains the necessary files.
5. **Ensure Proper Copying**: In the “builder” stage, make sure that you are copying the necessary files to the “/build/local-ai” directory. Verify that the “local-ai” directory is being created and populated with the required artifacts.
6. **Check Permissions**: Ensure that the user running the build has sufficient permissions to access the files in the build context and create directories within the container.
7. **Cleanup and Retry**: If the build fails, make sure to clean up any partially built images before retrying the build. You can use the following commands to remove any existing images or containers related to the build:
“`bash
docker rmi local-ai-builder
docker rm $(docker ps -aq)
“`
Once you’ve verified the “builder” stage and ensured that the necessary artifacts are generated, you can attempt the Docker build again:
“`bash
docker build -t local-ai .
“`
If the issue persists, please share relevant parts of the Dockerfile and additional details about the “builder” stage for further assistance.
FROM requirements as builder
ARG GO_TAGS=””
ENV GO_TAGS=${GO_TAGS}
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
ENV NVIDIA_REQUIRE_CUDA=”cuda>=${CUDA_MAJOR_VERSION}.0″
ENV NVIDIA_VISIBLE_DEVICES=all
WORKDIR /build
COPY Makefile .
RUN make get-sources
COPY go.mod .
RUN make prepare
COPY . .
COPY .git .
#RUN ESPEAK_DATA=/build/lib/Linux-$(uname -m)/piper_phonemize/lib/espeak-ng-data make build
###################################
###################################
FROM requirements
ARG FFMPEG
ENV REBUILD=false
ENV HEALTHCHECK_ENDPOINT=http://localhost:8080/readyz
# Add FFmpeg
RUN if [ “${FFMPEG}” = “true” ]; then
apt-get install -y ffmpeg
; fi
WORKDIR /build
# we start fresh & re-copy all assets because `make build` does not clean up nicely after itself
# so when `entrypoint.sh` runs `make build` again (which it does by default), the build would fail
# see https://github.com/go-skynet/LocalAI/pull/658#discussion_r1241971626 and
# https://github.com/go-skynet/LocalAI/pull/434
COPY . .
RUN make prepare-sources
COPY –from=builder /build/local-ai ./
# Define the health check command
HEALTHCHECK –interval=1m –timeout=10m –retries=10
CMD curl -f $HEALTHCHECK_ENDPOINT || exit 1
EXPOSE 8080
ENTRYPOINT [ “/build/entrypoint.sh” ]
Thank you for providing the full Dockerfile. The Dockerfile shows a multi-stage build, where it creates two stages named “builder” and “requirements.”
The “builder” stage seems to be responsible for fetching and building dependencies or artifacts, while the “requirements” stage sets up the runtime environment for the final image.
Looking at the second stage (“requirements”), it appears that the error you encountered could be related to the “COPY” command that copies the “local-ai” directory from the “builder” stage to the current stage.
To better understand and resolve the issue, here are some suggestions:
1. **Check the “local-ai” Directory**: In the “builder” stage, ensure that the “local-ai” directory is being generated with the necessary artifacts. You can use interactive debugging techniques (as explained in the previous response) to explore the “builder” stage and verify the contents of the “/build/local-ai” directory.
2. **Confirm “builder” Stage Success**: Make sure that the “builder” stage successfully completes without any errors. If there are issues in this stage, it might prevent the required files from being copied to the “requirements” stage.
3. **Verify Docker Build Context**: Ensure that all the required files and directories for the build process are present in the build context. Check if the files needed for the “local-ai” directory are accessible and included in the build context.
4. **Check Dockerignore**: Review the “.dockerignore” file (if present) in the build context. Ensure that it is not excluding any required files or directories, including those needed for the “local-ai” directory.
5. **Double Check “COPY” Command**: Ensure that the “COPY” command that copies the “local-ai” directory from the “builder” stage to the current stage is correct. The source path “/build/local-ai” should match the directory created in the “builder” stage.
6. **Check Permissions**: Ensure that the user running the build has sufficient permissions to access the files in the build context and create directories within the container.
7. **Use “docker buildx”**: If you are using Docker Buildx (as indicated in your previous messages), try using the `docker buildx` command to build the image. The “builder” stage might have been created with `docker buildx`, and using the same toolchain could help with compatibility.
Once you’ve verified the “builder” stage and ensured that the “local-ai” directory is generated successfully, attempt the Docker build again:
“`bash
docker build -t local-ai .
“`
If the issue persists, please provide any specific error messages or additional details about the “builder” stage for further assistance.
find the erro if you will:: ARG GO_VERSION=1.20-bullseye
FROM golang:$GO_VERSION as requirements
ARG BUILD_TYPE=cublas build
ARG CUDA_MAJOR_VERSION=11
ARG CUDA_MINOR_VERSION=7
# ARG SPDLOG_VERSION=”1.11.0″
# ARG PIPER_PHONEMIZE_VERSION=’1.0.0′
# ARG TARGETARCH
# ARG TARGETVARIANT
ENV BUILD_TYPE=${BUILD_TYPE}
ENV EXTERNAL_GRPC_BACKENDS=”huggingface-embeddings:/build/extra/grpc/huggingface/huggingface.py”
# Set the ESPEAK_DATA environment variable
#ENV ESPEAK_DATA /build/lib/Linux-$(uname -m)/piper_phonemize/lib/espeak-ng-data
ARG GO_TAGS=””
RUN apt-get update &&
apt-get install -y ca-certificates cmake curl patch pip
# Extras requirements
COPY extra/requirements.txt /build/extra/requirements.txt
RUN pip install -r /build/extra/requirements.txt && rm -rf /build/extra/requirements.txt
# CuBLAS requirements
RUN if [ “${BUILD_TYPE}” = “cublas” ]; then
apt-get install -y software-properties-common &&
apt-add-repository contrib &&
curl -O https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64/cuda-keyring_1.0-1_all.deb &&
dpkg -i cuda-keyring_1.0-1_all.deb &&
rm -f cuda-keyring_1.0-1_all.deb &&
apt-get update &&
apt-get install -y cuda-nvcc-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} libcublas-dev-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION}
; fi
ENV PATH /usr/local/cuda/bin:${PATH}
WORKDIR /build
# OpenBLAS requirements
#RUN apt-get install -y libopenblas-dev
# # Stable Diffusion requirements
# RUN apt-get install -y libopencv-dev &&
# ln -s /usr/include/opencv4/opencv2 /usr/include/opencv2
# Use the variables in subsequent instructions
RUN echo “Target Architecture: $TARGETARCH”
RUN echo “Target Variant: $TARGETVARIANT”
# piper requirements
# Use pre-compiled Piper phonemization library (includes onnxruntime)
RUN if echo “${GO_TAGS}” | grep -q “tts”; then
test -n “$TARGETARCH”
|| (echo ‘warn: missing $TARGETARCH, either set this `ARG` manually, or run using `docker buildkit`’);
fi
# RUN curl -L “https://github.com/gabime/spdlog/archive/refs/tags/v${SPDLOG_VERSION}.tar.gz” |
# tar -xzvf – &&
# mkdir -p “spdlog-${SPDLOG_VERSION}/build” &&
# cd “spdlog-${SPDLOG_VERSION}/build” &&
# cmake .. &&
# make -j8 &&
# cmake –install . –prefix /usr && mkdir -p “lib/Linux-$(uname -m)” &&
# cd /build &&
# mkdir -p “lib/Linux-$(uname -m)/piper_phonemize” &&
# curl -L “https://github.com/rhasspy/piper-phonemize/releases/download/v${PIPER_PHONEMIZE_VERSION}/libpiper_phonemize-${TARGETARCH:-$(go env GOARCH)}${TARGETVARIANT}.tar.gz” |
# tar -C “lib/Linux-$(uname -m)/piper_phonemize” -xzvf – && ls -liah /build/lib/Linux-$(uname -m)/piper_phonemize/ &&
# cp -rfv /build/lib/Linux-$(uname -m)/piper_phonemize/lib/. /lib64/ &&
# cp -rfv /build/lib/Linux-$(uname -m)/piper_phonemize/lib/. /usr/lib/ &&
# cp -rfv /build/lib/Linux-$(uname -m)/piper_phonemize/include/. /usr/include/; fi
###################################
###################################
FROM requirements as builder
ARG GO_TAGS=””
ENV GO_TAGS=${GO_TAGS}
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
ENV NVIDIA_REQUIRE_CUDA=”cuda>=${CUDA_MAJOR_VERSION}.0″
ENV NVIDIA_VISIBLE_DEVICES=all
WORKDIR /build
COPY Makefile .
RUN make get-sources
COPY go.mod .
RUN make prepare
COPY . .
COPY .git .
#RUN ESPEAK_DATA=/build/lib/Linux-$(uname -m)/piper_phonemize/lib/espeak-ng-data make build
###################################
###################################
FROM requirements
ARG FFMPEG
ENV REBUILD=false
ENV HEALTHCHECK_ENDPOINT=http://localhost:8080/readyz
# Add FFmpeg
RUN if [ “${FFMPEG}” = “true” ]; then
apt-get install -y ffmpeg
; fi
WORKDIR /build
# we start fresh & re-copy all assets because `make build` does not clean up nicely after itself
# so when `entrypoint.sh` runs `make build` again (which it does by default), the build would fail
# see https://github.com/go-skynet/LocalAI/pull/658#discussion_r1241971626 and
# https://github.com/go-skynet/LocalAI/pull/434
COPY . .
RUN make prepare-sources
COPY –from=builder /build/local-ai ./
# Define the health check command
HEALTHCHECK –interval=1m –timeout=10m –retries=10
CMD curl -f $HEALTHCHECK_ENDPOINT || exit 1
EXPOSE 8080
ENTRYPOINT [ “/build/entrypoint.sh” ]
The error seems to be related to the usage of the `make build` command, specifically the line `RUN ESPEAK_DATA=/build/lib/Linux-$(uname -m)/piper_phonemize/lib/espeak-ng-data make build` in the “builder” stage. The error is likely due to the missing definition of `ESPEAK_DATA`, causing the build to fail.
The `make build` command may require certain environment variables to be set for successful execution. In this case, it appears that `ESPEAK_DATA` needs to be defined before running the command.
To resolve the issue, you can try setting the `ESPEAK_DATA` environment variable in the “builder” stage, either as an ARG or directly with the `ENV` directive. You can define it before running the `make build` command. Modify your “builder” stage as follows:
“`Dockerfile
FROM requirements as builder
ARG GO_TAGS=””
ENV GO_TAGS=${GO_TAGS}
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
ENV NVIDIA_REQUIRE_CUDA=”cuda>=${CUDA_MAJOR_VERSION}.0″
ENV NVIDIA_VISIBLE_DEVICES=all
WORKDIR /build
COPY Makefile .
RUN make get-sources
COPY go.mod .
RUN make prepare
COPY . .
COPY .git .
# Set ESPEAK_DATA environment variable before running the make build command
ENV ESPEAK_DATA /build/lib/Linux-$(uname -m)/piper_phonemize/lib/espeak-ng-data
# Run the make build command
RUN make build
“`
By setting the `ESPEAK_DATA` environment variable explicitly before running the `make build` command, you provide the necessary definition required by the build process.
Additionally, since you are using multi-stage builds, you don’t need to copy the entire current directory to the final stage (“requirements”) as it is already present in the “builder” stage. You can remove the following line from the final stage:
“`Dockerfile
COPY . .
“`
With these modifications, try building the Docker image again:
“`bash
docker build -t local-ai .
“`
If there are any other specific error messages or issues during the build process, please provide them for further assistance.
=> ERROR [stage-2 5/5] COPY –from=builder /build/local-ai ./ 0.0s
——
> [stage-2 5/5] COPY –from=builder /build/local-ai ./:
——
Dockerfile:120
——————–
118 | COPY . .
119 | RUN make prepare-sources
120 | >>> COPY –from=builder /build/local-ai ./
121 |
122 | # Define the health check command
——————–
The error you encountered during the Docker build is related to the “COPY” command in the final stage of your Dockerfile. Specifically, it seems that the “/build/local-ai” directory from the “builder” stage is not found or not accessible during the copy operation.
Here are a few things to check and potential solutions:
1. **Check “builder” Stage**: Ensure that the “builder” stage (the one with the label “builder”) successfully creates the “/build/local-ai” directory and the necessary files within it. You can verify this by running the “builder” stage interactively as mentioned before:
“`bash
docker build -t local-ai-builder -f Dockerfile.builder .
docker run -it local-ai-builder /bin/bash
“`
Once inside the container, navigate to the “/build” directory and check if the “local-ai” directory exists with the required files.
2. **Double Check “builder” Stage Copy**: In the “builder” stage, make sure you are copying the “local-ai” directory to the right location within the container. The “COPY” command in the “builder” stage should be copying the “local-ai” directory to “/build/local-ai”.
3. **Check File Permissions**: Ensure that the user running the build has sufficient permissions to access the files in the “builder” stage and perform the copy operation. File permission issues can sometimes cause the “COPY” command to fail.
4. **Verify Docker Build Context**: Double-check the build context from which you are running the “docker build” command. Ensure that the necessary files, including the “local-ai” directory and its contents, are present within the build context.
5. **Use “docker buildx”**: If you are using Docker Buildx, make sure you are using the appropriate “docker buildx” command to build the image, especially if the “builder” stage was created with Buildx as well.
6. **Check Dockerignore**: Review the “.dockerignore” file in the build context. Ensure that it is not excluding any required files or directories, including those needed for the “local-ai” directory.
7. **Check for Typos**: Double-check for any typos in the “COPY” command or in the path of the source directory being copied from the “builder” stage.
If you are certain that the “builder” stage creates the “/build/local-ai” directory with the required files, and all the other aspects are in order, try rebuilding the “builder” stage, then rebuild the final stage again:
“`bash
# Rebuild the builder stage
docker build -t local-ai-builder -f Dockerfile.builder .
# Rebuild the final stage
docker build -t local-ai .
“`
If the issue persists, please share any additional error messages or any specific information that might help pinpoint the problem.
(GPTQ) gemini@DESKTOP-UNG8TH9:/mnt/d/SuperAGi/localai$ docker build -t local-ai-builder -f Dockerfile.builder .
[+] Building 0.2s (2/2) FINISHED docker:default
=> [internal] load build definition from Dockerfile.builder 0.1s
=> => transferring dockerfile: 2B 0.1s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 125B 0.1s
ERROR: failed to solve: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount3464810/Dockerfile.builder: no such file or directory
The error message “failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mountXXXX/Dockerfile.builder: no such file or directory” indicates that Docker Buildkit encountered an issue while trying to read the “Dockerfile.builder” file in the build context.
This error usually occurs when the “Dockerfile.builder” file is not present in the build context or if there’s a discrepancy in the specified path of the Dockerfile.
To resolve this issue, please double-check the following:
1. **Verify Dockerfile File**: Make sure the “Dockerfile.builder” file exists in the directory from which you are running the build command. Check the file name for any spelling mistakes or typos.
2. **Check Build Context**: Ensure that you are running the build command from the correct directory containing the “Dockerfile.builder” file. Use the `ls` command to list the contents of the current directory and verify that the Dockerfile is present.
3. **Use Absolute File Path**: If you are running the build command from a different location or if the Dockerfile is in a different directory, provide an absolute file path to the Dockerfile instead of a relative path. For example:
“`bash
docker build -t local-ai-builder -f /path/to/Dockerfile.builder .
“`
4. **Check Dockerignore**: Ensure that the “Dockerfile.builder” is not excluded in the “.dockerignore” file in the build context. If it is, remove the entry or modify the “.dockerignore” file accordingly.
5. **File Permissions**: Verify that you have sufficient permissions to read the “Dockerfile.builder” file. If needed, you can try running the build command with elevated privileges (e.g., using `sudo`).
If you have made any changes to the Dockerfile or its name, ensure that you are using the correct file name and path when running the build command.
After verifying the above points, try running the build command again:
“`bash
docker build -t local-ai-builder -f Dockerfile.builder .
“`
If the issue persists, please provide any additional information or error messages for further investigation.
I think I know the problem. The error doesn’t say the directory doesn’t exist it says it cannot find the config file.
I think I know the problem. The error doesn’t say the directory doesn’t exist it says it cannot find the config file.6:02PM ERR error loading config files: open /build/models: no such file or directory
Thank you for the update. If the error specifically mentions that it cannot find the config file, the issue might indeed be related to the location of the Dockerfile.builder or some other configuration problem. Let’s go through some steps to troubleshoot and resolve the issue:
1. **Verify File Location**: Ensure that the “Dockerfile.builder” exists in the correct location. Double-check the directory from which you are running the build command to make sure the file is present.
2. **Use Absolute File Path**: As mentioned earlier, try using an absolute file path when specifying the Dockerfile to ensure there’s no ambiguity in the location. For example:
“`bash
docker build -t local-ai-builder -f /path/to/Dockerfile.builder .
“`
3. **Check Dockerfile Content**: Review the content of the “Dockerfile.builder” to see if there are any references to other files or configurations that might be causing the error. Ensure that all file paths and configurations are accurate.
4. **Build Context**: Verify that the build context contains all the necessary files and directories required for the build process. Ensure that no files are unintentionally excluded in the “.dockerignore” file.
5. **Check Docker Build Context**: Ensure you are running the build command from the correct directory containing the Dockerfile.builder. If needed, navigate to the correct directory before executing the build command.
6. **Check Buildkit Configuration**: If you are using Docker Buildx or Buildkit, there might be specific configurations related to Buildkit that could cause the issue. Check your Buildkit configuration or try building without Buildkit to see if it makes a difference.
7. **Inspect Docker Build Logs**: If possible, inspect the Docker build logs for more detailed information about the error. You can use the `–progress=plain` option with the build command to see the full build output, including any error messages.
“`bash
docker build -t local-ai-builder -f /path/to/Dockerfile.builder . –progress=plain
“`
8. **Docker Buildx**: If you are using Docker Buildx, try using the “docker build” command without Buildx to see if the issue persists.
9. **Recreate Dockerfile.builder**: If the problem persists and none of the above steps resolve the issue, consider recreating the “Dockerfile.builder” from scratch or using a known-working version.
10. **Docker Version and Updates**: Ensure that you are using the latest version of Docker and that all necessary updates are installed. Some issues might be resolved by updating Docker to the latest stable release.
11. **Seek Community Support**: If the issue persists and you’ve exhausted all troubleshooting options, consider seeking support from the Docker community, forums, or GitHub repositories related to the project you are working on.
By following these steps and carefully reviewing the Dockerfile.builder and the build context, you should be able to identify and resolve the problem preventing the Docker build from finding the config file. If you encounter any specific error messages or logs, please provide them, and I’ll do my best to assist you further.
You are correct, and I apologize for the confusion. The error message “error loading config files: open /build/models: no such file or directory” indeed points to an issue with a missing directory rather than a missing Dockerfile.
The error is likely related to the “COPY” instruction in the final stage of your Dockerfile, where you are trying to copy files from the “builder” stage. Specifically, the issue is with copying the “/build/models” directory.
To fix this issue, you need to ensure that the “/build/models” directory is created and populated with the necessary files in the “builder” stage. Additionally, ensure that the correct files are being copied from the “builder” stage to the final stage.
Here are the steps to address the problem:
1. In the “builder” stage, make sure you create the “/build/models” directory and copy the required files into it.
2. Check that the necessary files are present in the “/build/models” directory in the “builder” stage before the “COPY” instruction.
3. Modify the “COPY” instruction in the final stage to copy the “/build/models” directory from the “builder” stage to the correct location in the final stage.
Here’s a modified version of your Dockerfile with the changes:
“`Dockerfile
# … Previous content of the Dockerfile …
###################################
### Your “builder” stage ###
###################################
FROM requirements as builder
# … Your “builder” stage instructions …
# Create and populate the /build/models directory
RUN mkdir -p /build/models
COPY models /build/models
# … Rest of your “builder” stage instructions …
###################################
### Your final stage ###
###################################
FROM requirements
# … Your final stage instructions …
# Copy /build/models directory from the builder stage
COPY –from=builder /build/models /build/models
# … Rest of your final stage instructions …
“`
With these changes, the “/build/models” directory and its contents will be copied correctly from the “builder” stage to the final stage, resolving the “no such file or directory” error.
After making the modifications, try rebuilding the Docker image:
“`bash
docker build -t local-ai .
“`
If there are any other specific error messages or issues during the build process, please provide them for further assistance.
OK. Time to delete everythin, clea it up and start over
Starting fresh and cleaning up your Docker environment can be a good approach when you encounter persistent issues during the build process. To do this, follow these steps:
1. **Stop and Remove Containers**: First, stop and remove any running containers to free up resources and ensure a clean environment. You can use the following commands to stop and remove all containers:
“`bash
# Stop all running containers
docker stop $(docker ps -aq)
# Remove all containers (including stopped ones)
docker rm $(docker ps -aq)
“`
2. **Remove Images**: Next, remove any existing images that you don’t need anymore. You can list all images and remove them with the following commands:
“`bash
# List all images
docker images
# Remove specific image(s)
docker rmi IMAGE_ID1 IMAGE_ID2 …
“`
Replace `IMAGE_ID1`, `IMAGE_ID2`, etc., with the IDs of the images you want to remove.
3. **Clean Up Dangling Resources**: Docker sometimes leaves behind unused resources called “dangling” resources. You can clean them up using:
“`bash
# Clean up dangling images
docker image prune
# Clean up dangling volumes
docker volume prune
# Clean up dangling networks
docker network prune
“`
4. **Delete Docker Builds**: If you have any previous Docker builds that you don’t need anymore, you can remove them as well:
“`bash
# List all Docker builds
docker build ls
# Remove specific build(s)
docker build rm BUILD_ID1 BUILD_ID2 …
“`
Replace `BUILD_ID1`, `BUILD_ID2`, etc., with the IDs of the builds you want to remove.
5. **Remove Docker Build Cache**: If you suspect that cached build layers might be causing issues, you can try removing the build cache:
“`bash
# Remove all cached build layers
docker builder prune
“`
6. **Clean Up Build Context**: Double-check the build context directory and remove any unnecessary or large files that you don’t need for the build.
7. **Verify Dockerfile and Config Files**: Make sure your Dockerfile and any other configuration files are correct and properly located within the build context.
8. **Rebuild the Docker Image**: Now, you can start the Docker build process from scratch:
“`bash
docker build -t local-ai .
“`
9. **Test the Container**: Once the build is successful, you can run the container and test its functionality:
“`bash
docker run -it -p 8080:8080 local-ai
“`
If your application exposes a web service on port 8080, you should be able to access it from your host machine’s web browser or by sending HTTP requests to `http://localhost:8080`.
By following these steps, you’ll have a fresh Docker environment, and you can start with a clean slate to troubleshoot any issues with your Docker build and container. If you encounter any specific errors or challenges during the process, feel free to ask for further assistance.
After cleanup, why is my dockerfile ext4.vhdx file so huge
The size of the Docker image (ext4.vhdx file) can be influenced by several factors. The Docker image is a combination of multiple layers, and the size of each layer depends on what’s included in the image during the build process. Here are some common reasons why a Docker image might be large:
1. **Layered File System**: Docker uses a layered file system, where each instruction in the Dockerfile creates a new layer. If you have many layers or large files added in different stages of the Dockerfile, the image size can grow significantly.
2. **Package Installations**: Installing packages (e.g., via `apt-get`, `pip`, or `npm`) can increase the image size, especially if the packages have many dependencies.
3. **Temporary Files and Caches**: Temporary files and cached build artifacts can be created during the build process and might not be cleaned up automatically, increasing the image size.
4. **Large Source Code**: If you copy a large amount of source code or data into the image (e.g., with the `COPY` instruction), it can increase the image size.
5. **Build Context**: The build context includes all files in the current directory and its subdirectories. If your build context contains unnecessary or large files, they will be included in the image, even if you don’t use them in the Dockerfile.
6. **Debug Symbols**: Sometimes, compiler settings or package installations include debug symbols, which can significantly increase the image size. In production, you may want to strip these symbols.
To reduce the size of your Docker image, consider the following optimizations:
1. **Multistage Builds**: Use multistage builds to separate the build environment from the runtime environment. This allows you to include only the necessary files in the final image while keeping the build tools in a separate intermediate image.
2. **Alpine Base Image**: If possible, use a smaller base image like Alpine Linux instead of full Linux distributions like Debian or Ubuntu.
3. **Cleanup After Installations**: Remove unnecessary files, caches, and temporary files after package installations. For example, use `apt-get clean` or `rm -rf /var/lib/apt/lists/*` to clean up package manager caches.
4. **Minimize Copy Operations**: Copy only the necessary files into the image. Use `.dockerignore` to exclude unnecessary files from the build context.
5. **Optimize Dependencies**: Check if any dependencies can be replaced with smaller alternatives or if you can remove unused dependencies.
6. **Use Smaller Libraries**: Opt for smaller libraries or lightweight alternatives when possible.
7. **Avoid Debug Symbols**: Ensure that you’re not including debug symbols or unnecessary debugging information in the final image.
By following these tips, you can optimize your Dockerfile and reduce the size of your Docker image, making it more efficient to distribute and deploy.
let’s do a complte wndows 10 cleanup
Performing a complete cleanup on Windows 10 involves several steps to free up disk space, remove unnecessary files, and optimize the system. Here’s a step-by-step guide to help you with the cleanup process:
**Step 1: Disk Cleanup**
1. Press the **Windows key + S**, type “**Disk Cleanup**,” and select the **Disk Cleanup** app from the search results.
2. Choose the drive you want to clean (usually the **C:** drive) and click **OK**.
3. Wait for the Disk Cleanup tool to calculate the space that can be freed.
4. Select the items you want to clean, such as Temporary files, Recycle Bin, and Downloaded Program Files.
5. Click **OK** and then **Delete Files** to confirm the cleanup.
**Step 2: Uninstall Unused Programs**
1. Press the **Windows key + I** to open the **Settings** app.
2. Go to **Apps > Apps & features**.
3. Uninstall any applications that you no longer need or use by selecting them and clicking **Uninstall**.
**Step 3: Delete Unnecessary Files and Folders**
1. Go to **C:UsersYourUsernameAppDataLocalTemp** and delete all the files and folders present in the Temp folder. These are temporary files that can be safely removed.
2. Similarly, go to **C:WindowsTemp** and delete the contents of the Temp folder.
**Step 4: Clean Windows Update Files**
1. Press the **Windows key + R** to open the **Run** dialog.
2. Type “**cleanmgr**” and click **OK**.
3. Select the **C:** drive (or the drive where Windows is installed) and click **OK**.
4. Click on **Clean up system files** and select the **Windows Update Cleanup** option. Click **OK** and then **Delete Files** to confirm.
**Step 5: Clean System Restore Points**
1. Press the **Windows key + S**, type “**System Restore**,” and select the **Create a restore point** option from the search results.
2. Click on **Configure** and then select **Delete** to remove older system restore points.
**Step 6: Disable Hibernation (Optional)**
1. Open a Command Prompt with administrative privileges (search for “**cmd**,” right-click, and choose **Run as administrator**).
2. Type “**powercfg.exe /hibernate off**” and press **Enter**. This will disable hibernation and remove the hiberfil.sys file.
**Step 7: Perform Disk Defragmentation (Optional)**
1. Type “**defragment and optimize drives**” in the search bar and open the **Defragment and Optimize Drives** app.
2. Select the drive you want to defragment (usually **C:**), and click **Optimize**.
**Step 8: Restart Your Computer**
After completing the cleanup steps, restart your computer to apply the changes and ensure that all temporary files are removed.
Remember that before making any changes to your system, it’s a good idea to back up important data to ensure you don’t lose any valuable files.
gptj.cpp:112:33: warning: comparison of integer expressions of different signedness: ‘std::vector::size_type’ {aka ‘long unsigned int’} and ‘int32_t’ {aka ‘int’} [-Wsign-compare]
112 | if (embd.size() > params.n_batch) {
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~
gptj.cpp:36:19: warning: unused variable ‘t_main_start_us’ [-Wunused-variable]
36 | const int64_t t_main_start_us = ggml_time_us();
| ^~~~~~~~~~~~~~~
gptj.cpp:48:13: warning: unused variable ‘t_load_us’ [-Wunused-variable]
48 | int64_t t_load_us = 0;
| ^~~~~~~~~
g++ -I. -I./ggml.cpp/include -I./ggml.cpp/include/ggml/ -I./ggml.cpp/examples/ -O3 -DNDEBUG -std=c++17 -fPIC -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wno-multichar -pthread -march=native -mtune=native mpt.cpp -o mpt.o -c
In file included from mpt.cpp:19:
ggml.cpp/examples/mpt/main.cpp: In function ‘bool mpt_model_load(const string&, mpt_model&, gpt_vocab&)’:
ggml.cpp/examples/mpt/main.cpp:246:31: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
246 | for (int w = 0; w < word_multibytes.size(); w++) {
| ~~^~~~~~~~~~~~~~~~~~~~~~~~
mpt.cpp: In function ‘int mpt_predict(void*, void*, char*)’:
mpt.cpp:37:19: warning: unused variable ‘t_main_start_us’ [-Wunused-variable]
37 | const int64_t t_main_start_us = ggml_time_us();
| ^~~~~~~~~~~~~~~
These messages are compiler warnings, not errors. While warnings are worth noting, they don't prevent your code from compiling or running. Warnings indicate potential issues in the code that you might want to address to improve the code's quality and avoid unexpected behavior. Let's take a look at the warnings:
1. `gptj.cpp:112:33: warning: comparison of integer expressions of different signedness`: This warning suggests that you are comparing values of different types, one being `std::vector::size_type` (which is usually an unsigned type) and the other being `int32_t` (which is a signed type). The warning encourages you to ensure that you are comparing compatible types. You can potentially fix this by converting one of the types to the other or by using a consistent type for the comparison.
2. `gptj.cpp:36:19: warning: unused variable ‘t_main_start_us’`: This warning indicates that the variable `t_main_start_us` is declared but not used in the code. To get rid of this warning, you can either remove the declaration of the unused variable or use it somewhere in your code.
3. `gptj.cpp:48:13: warning: unused variable ‘t_load_us’`: Similar to the previous warning, this one indicates that the variable `t_load_us` is declared but not used. You can address this warning by either removing the unused variable or using it in your code.
4. `ggml.cpp/examples/mpt/main.cpp:246:31: warning: comparison of integer expressions of different signedness`: This warning is similar to the first one but occurs in a different file (`ggml.cpp/examples/mpt/main.cpp`). It indicates a comparison between an `int` and a `std::__cxx11::basic_string::size_type`, which are different types. You can handle this warning similarly to the first one, by making sure you are comparing compatible types.
5. `mpt.cpp:37:19: warning: unused variable ‘t_main_start_us’`: This is the same warning as seen earlier about the unused variable `t_main_start_us`. The solution is the same as before.
Warnings, while important to address for code quality, are not blocking issues. If your code compiles and runs without errors, you can choose to address the warnings based on their relevance and impact on your codebase. If you decide to fix them, carefully review the locations of the warnings in your code and make appropriate changes.
the make was interrupted. Do I need to perform any clean up or rerun?
When a `make` process is interrupted, it might leave behind partially built files, which could lead to unexpected behavior if you try to continue the build later. To ensure a clean build after an interruption, it’s generally a good idea to perform a cleanup and then rerun the build process. Here’s what you can do:
**1. Clean up:**
Run the following command to clean up the partially built files:
“`
make clean
“`
The `make clean` target should remove any temporary or intermediate files created during the build process.
**2. Rerun the build:**
After cleaning up, you can rerun the build process:
“`
make
“`
Or if you have specific build targets, use them:
“`
make target_name
“`
This will initiate the build process from scratch and help avoid any potential issues caused by the previous interrupted build.
**3. Consider using `make -j`:**
If you have a multi-core processor, you can speed up the build process using the `-j` option. This option allows `make` to run multiple build tasks concurrently, taking advantage of multiple CPU cores.
For example, to run four build tasks concurrently, you can use:
“`
make -j4
“`
**4. Check for Errors:**
After rerunning the build, carefully check the output for any error messages or warnings. If there are no errors, and the build completes successfully, you should have a clean build.
Keep in mind that if the interruption occurred due to issues with your source code, dependencies, or build system, simply rerunning the build may not solve the underlying problem. In such cases, it’s essential to identify and fix the root cause of the interruption.
As a good practice, consider committing your code to a version control system before starting a build, so you can easily revert back to a known good state if needed.
usr/bin/ld: go-ggllm/libggllm.a(falcon_common.o): in function `gpt_params_parse(int, char**, gpt_params&)’:
falcon_common.cpp:(.text+0x409c): undefined reference to `ggml_cuda_set_max_gpus’
/usr/bin/ld: falcon_common.cpp:(.text+0x569c): undefined reference to `ggml_cuda_set_main_device’
/usr/bin/ld: falcon_common.cpp:(.text+0x5722): undefined reference to `ggml_cuda_set_max_gpus’
/usr/bin/ld: falcon_common.cpp:(.text+0x579e): undefined reference to `ggml_cuda_set_vram_reserved’
/usr/bin/ld: falcon_common.cpp:(.text+0x59cc): undefined reference to `ggml_cuda_set_tensor_split_prepare’
collect2: error: ld returned 1 exit status
make: *** [Makefile:346: backend-assets/grpc/falcon] Error 2
The error message indicates that the linker (`ld`) is unable to find the definitions for certain functions that are referenced in the `falcon_common.cpp` file. These functions seem to be related to `ggml_cuda`, and the linker is not able to resolve their symbols.
Here are a few possible reasons for this issue:
1. **Missing Library**: The functions `ggml_cuda_set_max_gpus`, `ggml_cuda_set_main_device`, `ggml_cuda_set_vram_reserved`, and `ggml_cuda_set_tensor_split_prepare` are defined in a library called `ggml_cuda`, and the linker is not finding this library. Make sure that the library is properly built and available to the linker during the build process.
2. **Incorrect Library Order**: The order in which libraries are specified during the linking process matters. If `ggml_cuda` depends on another library that comes later in the command line, the linker may not be able to resolve the symbols. Ensure that the library order is correct.
3. **Library Path**: If the `ggml_cuda` library is located in a non-standard directory, you might need to specify the library path to the linker using the `-L` option.
4. **Library Name**: Check that the library name is specified correctly. It should be provided to the linker without the `lib` prefix and the `.a` extension. For example, if the library is named `libggml_cuda.a`, you should specify it as `ggml_cuda`.
To debug the issue, you can try the following steps:
1. Check the build logs for any errors related to building the `ggml_cuda` library. Make sure it is built successfully.
2. Verify the library search paths and library order in the build command or the Makefile. Ensure that the correct directories and libraries are specified.
3. Ensure that the library name is correct and doesn’t include the `lib` prefix and `.a` extension.
4. If the library is installed in a custom location, consider adding the library path using the `-L` option in the linker command.
5. Make sure that the library files (`libggml_cuda.a` and other related libraries) are accessible and readable by the linker.
If you need further assistance, please provide more details about your build environment, the relevant parts of the Makefile or build script, and any other relevant information. This will help in providing a more specific solution to the linking issue.
look through the entire error message: # github.com/mudler/go-ggllm.cpp
/usr/bin/ld: go-ggllm/libggllm.a(libfalcon.o): in function `llama_free’:
libfalcon.cpp:(.text+0x5c01): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: libfalcon.cpp:(.text+0x5c47): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: libfalcon.cpp:(.text+0x5f5f): undefined reference to `ggml_cuda_free_data’
/usr/bin/ld: libfalcon.cpp:(.text+0x6025): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: libfalcon.cpp:(.text+0x6058): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: go-ggllm/libggllm.a(libfalcon.o): in function `falcon_prepare_buffers’:
libfalcon.cpp:(.text+0x6393): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: libfalcon.cpp:(.text+0x63a6): undefined reference to `ggml_cuda_host_malloc’
/usr/bin/ld: libfalcon.cpp:(.text+0x6472): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: libfalcon.cpp:(.text+0x6485): undefined reference to `ggml_cuda_host_malloc’
/usr/bin/ld: libfalcon.cpp:(.text+0x6541): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: libfalcon.cpp:(.text+0x6554): undefined reference to `ggml_cuda_host_malloc’
/usr/bin/ld: go-ggllm/libggllm.a(libfalcon.o): in function `falcon_eval_internal(falcon_context&, int const*, int, int, int, char const*, int)’:
libfalcon.cpp:(.text+0x8fd1): undefined reference to `ggml_cuda_assign_buffers’
/usr/bin/ld: go-ggllm/libggllm.a(libfalcon.o): in function `falcon_eval’:
libfalcon.cpp:(.text+0x99f7): undefined reference to `ggml_cuda_get_system_gpu_status’
/usr/bin/ld: libfalcon.cpp:(.text+0x9a19): undefined reference to `ggml_cuda_pool_purge_buffers_with_access_count’
/usr/bin/ld: libfalcon.cpp:(.text+0x9a27): undefined reference to `ggml_cuda_pool_reset_all_counters’
/usr/bin/ld: go-ggllm/libggllm.a(libfalcon.o): in function `falcon_model_load_internal(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, falcon_context&, int, int,
int, int, ggml_type, bool, bool, bool, void (*)(float, void*, char const*), void*)’:
libfalcon.cpp:(.text+0xc61b): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: libfalcon.cpp:(.text+0xc632): undefined reference to `ggml_cuda_host_malloc’
/usr/bin/ld: libfalcon.cpp:(.text+0xc726): undefined reference to `ggml_cuda_set_main_device’
/usr/bin/ld: libfalcon.cpp:(.text+0xc730): undefined reference to `ggml_cuda_update_gpu_status’
/usr/bin/ld: libfalcon.cpp:(.text+0xc735): undefined reference to `ggml_cuda_get_system_gpu_status’
/usr/bin/ld: libfalcon.cpp:(.text+0xc800): undefined reference to `ggml_cuda_set_scratch_size’
/usr/bin/ld: libfalcon.cpp:(.text+0xdd02): undefined reference to `ggml_cuda_update_gpu_status’
/usr/bin/ld: libfalcon.cpp:(.text+0xdd2b): undefined reference to `ggml_init_cublas’
/usr/bin/ld: go-ggllm/libggllm.a(libfalcon.o): in function `falcon_init_from_file’:
libfalcon.cpp:(.text+0xf51a): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: libfalcon.cpp:(.text+0xf52e): undefined reference to `ggml_cuda_host_malloc’
/usr/bin/ld: libfalcon.cpp:(.text+0xf73e): undefined reference to `ggml_cuda_assign_buffers_no_scratch’
/usr/bin/ld: libfalcon.cpp:(.text+0xf74b): undefined reference to `ggml_cuda_assign_buffers_no_scratch’
/usr/bin/ld: libfalcon.cpp:(.text+0xf7d7): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: libfalcon.cpp:(.text+0xf817): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: libfalcon.cpp:(.text+0xf88b): undefined reference to `ggml_cuda_free_data’
/usr/bin/ld: libfalcon.cpp:(.text+0xf94c): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: libfalcon.cpp:(.text+0xf97f): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: go-ggllm/libggllm.a(libfalcon.o): in function `falcon_init_from_file.cold’:
libfalcon.cpp:(.text.unlikely+0x16c8): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: libfalcon.cpp:(.text.unlikely+0x16f2): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: libfalcon.cpp:(.text.unlikely+0x1a9d): undefined reference to `ggml_cuda_free_data’
/usr/bin/ld: libfalcon.cpp:(.text.unlikely+0x1b5e): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: libfalcon.cpp:(.text.unlikely+0x1b91): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: go-ggllm/libggllm.a(libfalcon.o): in function `falcon_model::~falcon_model()’:
libfalcon.cpp:(.text._ZN12falcon_modelD2Ev[_ZN12falcon_modelD5Ev]+0x4f): undefined reference to `ggml_cuda_free_data’
/usr/bin/ld: libfalcon.cpp:(.text._ZN12falcon_modelD2Ev[_ZN12falcon_modelD5Ev]+0x10e): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: libfalcon.cpp:(.text._ZN12falcon_modelD2Ev[_ZN12falcon_modelD5Ev]+0x13d): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: go-ggllm/libggllm.a(libfalcon.o): in function `llama_model_loader::load_all_data(void (*)(float, void*, char const*), void*, llama_mlock*)’:
libfalcon.cpp:(.text._ZN18llama_model_loader13load_all_dataEPFvfPvPKcES0_P11llama_mlock[_ZN18llama_model_loader13load_all_dataEPFvfPvPKcES0_P11llama_mlock]+0x2e0): undefined reference to `ggml_cuda_transform_tensor’
/usr/bin/ld: go-ggllm/libggllm.a(libfalcon.o): in function `falcon_file_loader::read_vocab()’:
libfalcon.cpp:(.text._ZN18falcon_file_loader10read_vocabEv[_ZN18falcon_file_loader10read_vocabEv]+0x1b66): undefined reference to `ggml_init_cublas’
/usr/bin/ld: libfalcon.cpp:(.text._ZN18falcon_file_loader10read_vocabEv[_ZN18falcon_file_loader10read_vocabEv]+0x1f26): undefined reference to `ggml_init_cublas’
/usr/bin/ld: go-ggllm/libggllm.a(ggml.o): in function `ggml_init_cublas_wrapper’:
ggml.c:(.text+0x4b7b): undefined reference to `ggml_init_cublas’
/usr/bin/ld: go-ggllm/libggllm.a(ggml.o): in function `ggml_init’:
ggml.c:(.text+0x1a931): undefined reference to `ggml_init_cublas’
/usr/bin/ld: ggml.c:(.text+0x1aa19): undefined reference to `ggml_cuda_update_gpu_status’
/usr/bin/ld: go-ggllm/libggllm.a(ggml.o): in function `ggml_graph_compute_thread’:
ggml.c:(.text+0x363f8): undefined reference to `ggml_cuda_compute_forward’
/usr/bin/ld: ggml.c:(.text+0x364c7): undefined reference to `ggml_cuda_compute_forward’
/usr/bin/ld: ggml.c:(.text+0x36547): undefined reference to `ggml_cuda_compute_forward’
/usr/bin/ld: ggml.c:(.text+0x365e4): undefined reference to `ggml_cuda_compute_forward’
/usr/bin/ld: ggml.c:(.text+0x36628): undefined reference to `ggml_cuda_compute_forward’
/usr/bin/ld: go-ggllm/libggllm.a(ggml.o): in function `ggml_graph_compute’:
ggml.c:(.text+0x36a1f): undefined reference to `ggml_cuda_can_mul_mat’
/usr/bin/ld: go-ggllm/libggllm.a(falcon_common.o): in function `gpt_params_parse(int, char**, gpt_params&)’:
falcon_common.cpp:(.text+0x409c): undefined reference to `ggml_cuda_set_max_gpus’
/usr/bin/ld: falcon_common.cpp:(.text+0x569c): undefined reference to `ggml_cuda_set_main_device’
/usr/bin/ld: falcon_common.cpp:(.text+0x5722): undefined reference to `ggml_cuda_set_max_gpus’
/usr/bin/ld: falcon_common.cpp:(.text+0x579e): undefined reference to `ggml_cuda_set_vram_reserved’
/usr/bin/ld: falcon_common.cpp:(.text+0x59cc): undefined reference to `ggml_cuda_set_tensor_split_prepare’
collect2: error: ld returned 1 exit status
make: *** [Makefile:346: backend-assets/grpc/falcon] Error 2
The error message indicates that there are multiple undefined references to various functions related to `ggml_cuda` throughout the code. This typically happens when the necessary libraries or object files containing these functions are not linked properly during the build process.
To resolve this issue, follow these steps:
1. **Check Library Dependencies**: Ensure that all the required libraries (`ggml_cuda`, `ggml`, etc.) are properly built and available. Check if the library paths and names are correctly specified during the linking process.
2. **Library Order**: The order in which libraries are specified during the linking process matters. If library B depends on library A, then library A should be listed before library B in the linker command. Check the order of libraries specified in the build process.
3. **Check Library Paths**: If the libraries are installed in non-standard locations, make sure to provide the correct library paths using the `-L` option during the linking step.
4. **Library Name**: Verify that the library name is specified correctly without the `lib` prefix and the `.a` extension.
5. **Check Compiler Flags**: Ensure that any necessary compiler flags or options required by the libraries (e.g., `-D` for defining macros) are provided during the compilation and linking stages.
6. **Rebuild Dependencies**: If there have been recent changes to the libraries or related code, it’s possible that the dependencies are not up to date. Try rebuilding the required libraries (`ggml_cuda`, `ggml`, etc.) before building the main application.
7. **Check Include Paths**: Verify that the include paths are correctly set up, allowing the code to find the necessary header files for the libraries.
8. **Check Makefile or Build Script**: Review the Makefile or build script to ensure that all necessary flags, options, and libraries are included in the build process.
9. **Check Compiler Version**: Sometimes, using an older or incompatible version of the compiler can lead to issues with linking. Ensure that you are using the correct and compatible version of the compiler.
10. **Debugging**: If the issue persists, you may need to add additional debugging information to the build process, such as `-v` flag for verbose output, to understand where the linking process is failing.
Please carefully review each of these points and make sure that all necessary dependencies and options are correctly set up during the build. If you need further assistance, please provide more details about your build environment, the relevant parts of the Makefile or build script, and any other relevant information. This will help in providing a more specific solution to the linking issue.
here is the go-gglm makefile: INCLUDE_PATH := $(abspath ./)
LIBRARY_PATH := $(abspath ./)
ifndef UNAME_S
UNAME_S := $(shell uname -s)
endif
ifndef UNAME_P
UNAME_P := $(shell uname -p)
endif
ifndef UNAME_M
UNAME_M := $(shell uname -m)
endif
CCV := $(shell $(CC) –version | head -n 1)
CXXV := $(shell $(CXX) –version | head -n 1)
# Mac OS + Arm can report x86_64
# ref: https://github.com/ggerganov/whisper.cpp/issues/66#issuecomment-1282546789
ifeq ($(UNAME_S),Darwin)
ifneq ($(UNAME_P),arm)
SYSCTL_M := $(shell sysctl -n hw.optional.arm64 2>/dev/null)
ifeq ($(SYSCTL_M),1)
# UNAME_P := arm
# UNAME_M := arm64
warn := $(warning Your arch is announced as x86_64, but it seems to actually be ARM64. Not fixing that can lead to bad performance. For more info see: https://github.com/ggerganov/whisper.cpp/issues/66#issuecomment-1282546789)
endif
endif
endif
#
# Compile flags
#
BUILD_TYPE?=
# keep standard at C11 and C++11
CFLAGS = -I./ggllm.cpp -I. -O3 -DNDEBUG -std=c11 -fPIC
CXXFLAGS = -I./ggllm.cpp -I. -I./ggllm.cpp/examples -I./examples -O3 -DNDEBUG -std=c++11 -fPIC
LDFLAGS =
# warnings
CFLAGS += -Wall -Wextra -Wpedantic -Wcast-qual -Wdouble-promotion -Wshadow -Wstrict-prototypes -Wpointer-arith -Wno-unused-function
CXXFLAGS += -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function
# OS specific
# TODO: support Windows
ifeq ($(UNAME_S),Linux)
CFLAGS += -pthread
CXXFLAGS += -pthread
endif
ifeq ($(UNAME_S),Darwin)
CFLAGS += -pthread
CXXFLAGS += -pthread
endif
ifeq ($(UNAME_S),FreeBSD)
CFLAGS += -pthread
CXXFLAGS += -pthread
endif
ifeq ($(UNAME_S),NetBSD)
CFLAGS += -pthread
CXXFLAGS += -pthread
endif
ifeq ($(UNAME_S),OpenBSD)
CFLAGS += -pthread
CXXFLAGS += -pthread
endif
ifeq ($(UNAME_S),Haiku)
CFLAGS += -pthread
CXXFLAGS += -pthread
endif
# Architecture specific
# TODO: probably these flags need to be tweaked on some architectures
# feel free to update the Makefile for your architecture and send a pull request or issue
ifeq ($(UNAME_M),$(filter $(UNAME_M),x86_64 i686))
# Use all CPU extensions that are available:
CFLAGS += -march=native -mtune=native
endif
ifneq ($(filter ppc64%,$(UNAME_M)),)
POWER9_M := $(shell grep “POWER9″ /proc/cpuinfo)
ifneq (,$(findstring POWER9,$(POWER9_M)))
CFLAGS += -mcpu=power9
CXXFLAGS += -mcpu=power9
endif
# Require c++23’s std::byteswap for big-endian support.
ifeq ($(UNAME_M),ppc64)
CXXFLAGS += -std=c++23 -DGGML_BIG_ENDIAN
endif
endif
ifndef LLAMA_NO_ACCELERATE
# Mac M1 – include Accelerate framework.
# `-framework Accelerate` works on Mac Intel as well, with negliable performance boost (as of the predict time).
ifeq ($(UNAME_S),Darwin)
CFLAGS += -DGGML_USE_ACCELERATE
LDFLAGS += -framework Accelerate
endif
endif
ifdef LLAMA_OPENBLAS
CFLAGS += -DGGML_USE_OPENBLAS -I/usr/local/include/openblas
LDFLAGS += -lopenblas
endif
ifdef LLAMA_GPROF
CFLAGS += -pg
CXXFLAGS += -pg
endif
ifneq ($(filter aarch64%,$(UNAME_M)),)
CFLAGS += -mcpu=native
CXXFLAGS += -mcpu=native
endif
ifneq ($(filter armv6%,$(UNAME_M)),)
# Raspberry Pi 1, 2, 3
CFLAGS += -mfpu=neon-fp-armv8 -mfp16-format=ieee -mno-unaligned-access
endif
ifneq ($(filter armv7%,$(UNAME_M)),)
# Raspberry Pi 4
CFLAGS += -mfpu=neon-fp-armv8 -mfp16-format=ieee -mno-unaligned-access -funsafe-math-optimizations
endif
ifneq ($(filter armv8%,$(UNAME_M)),)
# Raspberry Pi 4
CFLAGS += -mfp16-format=ieee -mno-unaligned-access
endif
ifeq ($(BUILD_TYPE),openblas)
EXTRA_LIBS=
CMAKE_ARGS+=-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS -DBLAS_INCLUDE_DIRS=/usr/include/openblas
endif
ifeq ($(BUILD_TYPE),blis)
EXTRA_LIBS=
CMAKE_ARGS+=-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=FLAME
endif
ifeq ($(BUILD_TYPE),cublas)
EXTRA_LIBS=
CMAKE_ARGS+=-DLLAMA_CUBLAS=ON
EXTRA_TARGETS+=ggllm.cpp/ggml-cuda.o
endif
ifeq ($(BUILD_TYPE),clblas)
EXTRA_LIBS=
CMAKE_ARGS+=-DLLAMA_CLBLAST=ON
EXTRA_TARGETS+=ggllm.cpp/ggml-opencl.o
endif
ifeq ($(BUILD_TYPE),metal)
EXTRA_LIBS=
CGO_LDFLAGS+=”-framework Accelerate -framework Foundation -framework Metal -framework MetalKit -framework MetalPerformanceShaders”
CMAKE_ARGS+=-DLLAMA_METAL=ON
EXTRA_TARGETS+=ggllm.cpp/ggml-metal.o
endif
ifdef CLBLAST_DIR
CMAKE_ARGS+=-DCLBlast_dir=$(CLBLAST_DIR)
endif
#
# Print build information
#
$(info I ggllm.cpp build info: )
$(info I UNAME_S: $(UNAME_S))
$(info I UNAME_P: $(UNAME_P))
$(info I UNAME_M: $(UNAME_M))
$(info I CFLAGS: $(CFLAGS))
$(info I CXXFLAGS: $(CXXFLAGS))
$(info I CGO_LDFLAGS: $(CGO_LDFLAGS))
$(info I LDFLAGS: $(LDFLAGS))
$(info I BUILD_TYPE: $(BUILD_TYPE))
$(info I CMAKE_ARGS: $(CMAKE_ARGS))
$(info I EXTRA_TARGETS: $(EXTRA_TARGETS))
$(info I CC: $(CCV))
$(info I CXX: $(CXXV))
$(info )
# Use this if you want to set the default behavior
ggllm.cpp/ggml.o: prepare
mkdir -p build
cd build && cmake ../ggllm.cpp $(CMAKE_ARGS) && VERBOSE=1 cmake –build . –config Release && cp -rf CMakeFiles/ggml.dir/ggml.c.o ../ggllm.cpp/ggml.o
ggllm.cpp/ggml-cuda.o: ggllm.cpp/ggml.o
cd build && cp -rf CMakeFiles/ggml.dir/ggml-cuda.cu.o ../ggllm.cpp/ggml-cuda.o
ggllm.cpp/ggml-opencl.o: ggllm.cpp/ggml.o
cd build && cp -rf CMakeFiles/ggml.dir/ggml-opencl.cpp.o ../ggllm.cpp/ggml-opencl.o
ggllm.cpp/ggml-metal.o: ggllm.cpp/ggml.o
cd build && cp -rf CMakeFiles/ggml.dir/ggml-metal.m.o ../ggllm.cpp/ggml-metal.o
ggllm.cpp/k_quants.o: ggllm.cpp/ggml.o
cd build && cp -rf CMakeFiles/ggml.dir/k_quants.c.o ../ggllm.cpp/k_quants.o
ggllm.cpp/llama.o:
cd build && cp -rf CMakeFiles/llama.dir/llama.cpp.o ../ggllm.cpp/llama.o
ggllm.cpp/libfalcon.o:
cd build && cp -rf CMakeFiles/falcon.dir/libfalcon.cpp.o ../ggllm.cpp/libfalcon.o
ggllm.cpp/falcon_common.o:
cd build && cp -rf examples/CMakeFiles/falcon_common.dir/falcon_common.cpp.o ../ggllm.cpp/falcon_common.o
ggllm.cpp/cmpnct_unicode.o:
cd build && cp -rf CMakeFiles/cmpnct_unicode.dir/cmpnct_unicode.cpp.o ../ggllm.cpp/cmpnct_unicode.o
falcon_binding.o: prepare ggllm.cpp/ggml.o ggllm.cpp/cmpnct_unicode.o ggllm.cpp/llama.o ggllm.cpp/libfalcon.o ggllm.cpp/falcon_common.o
$(CXX) $(CXXFLAGS) -I./ggllm.cpp -I./ggllm.cpp/examples falcon_binding.cpp -o falcon_binding.o -c $(LDFLAGS)
## https://github.com/ggerganov/llama.cpp/pull/1902
prepare:
cd ggllm.cpp && patch -p1 share/man
drwxr-xr-x 2 root root 4096 Apr 18 17:35 sbin
drwxr-xr-x 5 root root 4096 May 5 22:02 share
drwxr-xr-x 2 root root 4096 Apr 18 17:35 src
It seems that there is no `cuda` directory directly under `/usr/local/`. This suggests that CUDA might not have been installed in the default location.
Since you already have CUDA version 11.5 installed, it’s possible that it was installed in a custom directory. Let’s try to locate it by performing a system-wide search for the `cuda` directory. Please run the following command:
“`
sudo find / -type d -name “cuda”
“`
This command will search the entire system for directories named “cuda”. If CUDA is installed on your system, it should display the path to the `cuda` directory.
Please note that the search may take some time, and you’ll need to enter your password as the `sudo` command requires elevated privileges.
Let me know if you find the CUDA installation directory or if you need any further assistance!
sudo find / -type d -name “cuda”
[sudo] password for gemini:
/usr/lib/cuda
/usr/share/doc/libthrust-dev/examples/cuda
/usr/include/thrust/system/cuda
/usr/include/cuda
find: File system loop detected; ‘/sys/kernel/debug/device_component’ is part of the same file system loop as ‘/sys/kernel/debug’.
/home/gemini/text-gen-install/installer_files/conda/pkgs/cuda-cccl-11.7.58-hc415cf5_0/include/thrust/system/cuda
/home/gemini/text-gen-install/installer_files/conda/pkgs/cuda-cccl-11.7.58-hc415cf5_0/include/cuda
/home/gemini/.local/lib/python3.10/site-packages/triton/third_party/cuda
/home/gemini/.local/lib/python3.10/site-packages/torch/backends/cuda
/home/gemini/.local/lib/python3.10/site-packages/torch/cuda
/home/gemini/.local/lib/python3.10/site-packages/torch/include/c10/cuda
/home/gemini/.local/lib/python3.10/site-packages/torch/include/ATen/native/cuda
/home/gemini/.local/lib/python3.10/site-packages/torch/include/ATen/cuda
/home/gemini/.local/lib/python3.10/site-packages/torch/include/torch/csrc/jit/codegen/cuda
/home/gemini/.local/lib/python3.10/site-packages/torch/include/torch/csrc/cuda
/home/gemini/miniconda3/lib/python3.10/site-packages/transformers/kernels/deformable_detr/cuda
/home/gemini/miniconda3/envs/GPTQ/lib/python3.10/site-packages/transformers/kernels/deformable_detr/cuda
find: File system loop detected; ‘/mnt/wslg/distro’ is part of the same file system loop as ‘/’.
It looks like CUDA is installed in multiple locations on your system. The main CUDA installation directories are typically `/usr/lib/cuda` and `/usr/include/cuda`. However, there are also CUDA-related directories within specific Python packages and other directories.
For most cases, the main CUDA installation directory is sufficient for compiling and linking CUDA programs. Let’s try to confirm the version of CUDA installed in `/usr/lib/cuda`. Please run the following command:
“`
ls /usr/lib/cuda
“`
This should display the version of CUDA installed in that directory. Additionally, you can check the contents of the `/usr/include/cuda` directory to verify the CUDA headers.
Let me know the output of the above command, and if you have any specific use case in mind, please let me know, and I can guide you accordingly.
ls /usr/lib/cuda
bin include lib64 nvvm
Great! The output indicates that you have CUDA installed in the `/usr/lib/cuda` directory, and it contains the following subdirectories:
– `bin`: This directory likely contains CUDA-related binaries, including the NVIDIA GPU compiler (`nvcc`) and other utility programs.
– `include`: This directory should contain CUDA header files needed for developing CUDA applications.
– `lib64`: This directory might contain CUDA libraries and runtime files for 64-bit systems.
– `nvvm`: This directory is related to the NVIDIA NVVM (NVIDIA Virtual Machine) compiler used by CUDA.
Since CUDA is installed in the standard location, you should be able to use it for compiling and running CUDA programs without any additional configuration. If you encounter any issues related to CUDA paths or environment variables, please let me know, and I’ll be happy to assist you further.
If you have a specific CUDA project or task you’d like to perform, feel free to share more details, and I can help you with the necessary steps or commands.
les make sure the path is set in the system
To ensure that the CUDA path is set correctly in your system, you need to set the necessary environment variables. In most cases, the CUDA installer should automatically set the required environment variables. However, it’s a good practice to verify them and make sure they are correctly configured.
1. First, check if the environment variable `PATH` includes the CUDA binaries directory. Open a terminal and type:
“`bash
echo $PATH
“`
Make sure that the output includes the CUDA binaries directory (e.g., `/usr/lib/cuda/bin`). If it’s not present, you’ll need to add it to your `PATH` environment variable.
2. Next, verify the CUDA library path. Check if the environment variable `LD_LIBRARY_PATH` includes the CUDA libraries directory. Type:
“`bash
echo $LD_LIBRARY_PATH
“`
Ensure that the output contains the CUDA libraries directory (e.g., `/usr/lib/cuda/lib64`). If it’s not there, you’ll need to add it to your `LD_LIBRARY_PATH` environment variable.
3. If the CUDA environment variables are missing, you can set them manually. Open your shell’s configuration file (e.g., `~/.bashrc` or `~/.bash_profile`) with a text editor:
“`bash
nano ~/.bashrc
“`
Add the following lines to the end of the file:
“`bash
export PATH=/usr/lib/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/lib/cuda/lib64:$LD_LIBRARY_PATH
“`
Save the file and exit the text editor.
4. To apply the changes immediately, either restart your terminal or execute the following command:
“`bash
source ~/.bashrc
“`
5. After setting the environment variables, you can verify if CUDA is correctly configured by running:
“`bash
nvcc –version
“`
This command should display information about the NVIDIA CUDA compiler version, confirming that CUDA is accessible through the environment variables.
Now your system should be properly set up to use CUDA. If you encounter any issues or need further assistance, feel free to let me know!
/home/gemini/.local/bin:/home/gemini/miniconda3/bin:/home/gemini/miniconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.7/bin:/mnt/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.7/libnvvp:/mnt/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.1/bin:/mnt/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.1/libnvvp:/mnt/c/ProgramData/miniconda3/condabin:/mnt/c/Program Files/Oculus/Support/oculus-runtime:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Windows/System32/OpenSSH:/mnt/c/ProgramData/chocolatey/bin:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/Microsoft SQL Server/150/Tools/Binn:/mnt/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn:/mnt/c/Program Files/Git LFS:/mnt/c/Program Files/CMake/bin:/mnt/c/Program Files/TorchStudio/bin:/mnt/c/Users/Sarah/AppData/Local/ActiveState/StateTool/release/bin:/mnt/c/Users/Sarah/AppData/Local/activestate/cache/bin:/mnt/c/Users/Sarah/AppData/Local/Programs/Python/Python310/Scripts:/mnt/c/Users/Sarah/AppData/Local/Programs/Python/Python310:/mnt/c/Users/Sarah/AppData/Local/Programs/Python/Python311/Scripts:/mnt/c/Users/Sarah/AppData/Local/Programs/Python/Python311:/mnt/c/Users/Sarah/AppData/Local/Programs/Python/Python37/Scripts:/mnt/c/Users/Sarah/AppData/Roaming/Python/Python310/Scripts/pipdeptree:/mnt/c/Users/Sarah/AppDat:/mnt/c/Program Files/nodejs:/mnt/c/Program Files/wkhtmltopdf/bin:/mnt/c/Program Files/wkhtmltopdf:/mnt/c/users/sarah/appdata/roaming/python/python37/site-packages:/mnt/c/Program Files/NVIDIA Corporation/NVSMI:/mnt/c/Program Files/dotnet:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/NVIDIA Corporation/Nsight Compute 2022.2.0:/mnt/e/users/sarah/.cache/huggingface:/mnt/c/Program Files/Go/bin:/mnt/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.1/extras/CUPTI/lib64:/mnt/c/ProgramData/miniconda3/condabin:/mnt/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.7/bin:/mnt/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.7/libnvvp:/mnt/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.1/bin:/mnt/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.1/libnvvp:/mnt/c/ProgramData/miniconda3/condabin:/mnt/c/Program Files/Oculus/Support/oculus-runtime:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Windows/System32/OpenSSH:/mnt/c/ProgramData/chocolatey/bin:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/Microsoft SQL Server/150/Tools/Binn:/mnt/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn:/mnt/c/Program Files/Git LFS:/mnt/c/Program Files/CMake/bin:/mnt/c/Program Files/TorchStudio/bin:/mnt/c/Users/Sarah/AppData/Local/ActiveState/StateTool/release/bin:/mnt/c/Users/Sarah/AppData/Local/activestate/cache/bin:/mnt/c/Users/Sarah/AppData/Local/Programs/Python/Python310/Scripts:/mnt/c/Users/Sarah/AppData/Roaming/Python/Python310/Scripts/pipdeptree:/mnt/e/users/sarah/.cache/huggingface:/mnt/c/Users/Sarah/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/Sarah/go/bin:/snap/bin
Thank you for providing the `PATH` environment variable. I can see that the CUDA binary path is present in the `PATH` variable, which means CUDA should be accessible from the command line.
To further verify the CUDA installation, you can execute the following command to check the NVIDIA driver and CUDA version:
“`bash
nvidia-smi
“`
This command will display information about your NVIDIA GPU, driver version, and CUDA version.
Additionally, you can check the CUDA compiler version by running:
“`bash
nvcc –version
“`
This will show the version of the NVIDIA CUDA compiler installed on your system.
If both of these commands provide output without any errors, it confirms that your CUDA installation is correctly set up and accessible from the command line. You should now be able to use CUDA for GPU-accelerated computing tasks.
echo $LD_LIBRARY_PATH
(base) gemini@DESKTOP-UNG8TH9:/usr$
It seems that the `LD_LIBRARY_PATH` environment variable is not set in your current shell session, which is why there is no output when you run `echo $LD_LIBRARY_PATH`. The absence of this variable might not be an issue, as most systems don’t require it to be explicitly set for CUDA to work properly.
The `LD_LIBRARY_PATH` environment variable is used to specify additional directories where the system should look for shared libraries at runtime. By default, important system directories like `/usr/lib` and `/usr/local/lib` are already included in the default library search path, so it’s generally not necessary to set `LD_LIBRARY_PATH` unless you have specific requirements.
Since your CUDA installation is present in `/usr/lib/cuda`, the system should be able to locate the necessary CUDA libraries without needing `LD_LIBRARY_PATH` to be explicitly set.
If you encounter any issues related to shared libraries when running CUDA applications or other programs, you might want to check if the necessary libraries are properly installed in the system library directories or if there are any specific library path configurations required for your applications. In most cases, such configurations are automatically managed by the CUDA installer.
Overall, if your CUDA applications are working as expected, you don’t need to worry about `LD_LIBRARY_PATH` for CUDA. However, if you encounter any issues, checking the library configurations and paths might be helpful.
This is the problem we are working on. We have now determined where the libraries are located, do they match and is this the pronlem? cd build && cp -rf CMakeFiles/ggml.dir/k_quants.c.o ../ggllm.cpp/k_quants.o
ar src libggllm.a ggllm.cpp/libfalcon.o ggllm.cpp/cmpnct_unicode.o ggllm.cpp/ggml.o ggllm.cpp/k_quants.o ggllm.cpp/falcon_common.o falcon_binding.o
make[1]: Leaving directory ‘/mnt/c/SarahOne/SuperAgi/app/localai/go-ggllm’
CGO_LDFLAGS=”” C_INCLUDE_PATH=/mnt/c/SarahOne/SuperAgi/app/localai/go-ggllm LIBRARY_PATH=/mnt/c/SarahOne/SuperAgi/app/localai/go-ggllm
go build -ldflags “-X “github.com/go-skynet/LocalAI/internal.Version=v1.23.0-10-g32ca7ef” -X “github.com/go-skynet/LocalAI/internal.Commit=32ca7efbeb72185d733f907247b5e409c064bfeb”” -tags “” -o backend-assets/grpc/falcon ./cmd/grpc/falcon/
# github.com/mudler/go-ggllm.cpp
/usr/bin/ld: go-ggllm/libggllm.a(libfalcon.o): in function `llama_free’:
libfalcon.cpp:(.text+0x5c01): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: libfalcon.cpp:(.text+0x5c47): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: libfalcon.cpp:(.text+0x5f5f): undefined reference to `ggml_cuda_free_data’
/usr/bin/ld: libfalcon.cpp:(.text+0x6025): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: libfalcon.cpp:(.text+0x6058): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: go-ggllm/libggllm.a(libfalcon.o): in function `falcon_prepare_buffers’:
libfalcon.cpp:(.text+0x6393): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: libfalcon.cpp:(.text+0x63a6): undefined reference to `ggml_cuda_host_malloc’
/usr/bin/ld: libfalcon.cpp:(.text+0x6472): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: libfalcon.cpp:(.text+0x6485): undefined reference to `ggml_cuda_host_malloc’
/usr/bin/ld: libfalcon.cpp:(.text+0x6541): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: libfalcon.cpp:(.text+0x6554): undefined reference to `ggml_cuda_host_malloc’
/usr/bin/ld: go-ggllm/libggllm.a(libfalcon.o): in function `falcon_eval_internal(falcon_context&, int const*, int, int, int, char const*, int)’:
libfalcon.cpp:(.text+0x8fd1): undefined reference to `ggml_cuda_assign_buffers’
/usr/bin/ld: go-ggllm/libggllm.a(libfalcon.o): in function `falcon_eval’:
libfalcon.cpp:(.text+0x99f7): undefined reference to `ggml_cuda_get_system_gpu_status’
/usr/bin/ld: libfalcon.cpp:(.text+0x9a19): undefined reference to `ggml_cuda_pool_purge_buffers_with_access_count’
/usr/bin/ld: libfalcon.cpp:(.text+0x9a27): undefined reference to `ggml_cuda_pool_reset_all_counters’
/usr/bin/ld: go-ggllm/libggllm.a(libfalcon.o): in function `falcon_model_load_internal(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, falcon_context&, int, int,
int, int, ggml_type, bool, bool, bool, void (*)(float, void*, char const*), void*)’:
libfalcon.cpp:(.text+0xc61b): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: libfalcon.cpp:(.text+0xc632): undefined reference to `ggml_cuda_host_malloc’
/usr/bin/ld: libfalcon.cpp:(.text+0xc726): undefined reference to `ggml_cuda_set_main_device’
/usr/bin/ld: libfalcon.cpp:(.text+0xc730): undefined reference to `ggml_cuda_update_gpu_status’
/usr/bin/ld: libfalcon.cpp:(.text+0xc735): undefined reference to `ggml_cuda_get_system_gpu_status’
/usr/bin/ld: libfalcon.cpp:(.text+0xc800): undefined reference to `ggml_cuda_set_scratch_size’
/usr/bin/ld: libfalcon.cpp:(.text+0xdd02): undefined reference to `ggml_cuda_update_gpu_status’
/usr/bin/ld: libfalcon.cpp:(.text+0xdd2b): undefined reference to `ggml_init_cublas’
/usr/bin/ld: go-ggllm/libggllm.a(libfalcon.o): in function `falcon_init_from_file’:
libfalcon.cpp:(.text+0xf51a): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: libfalcon.cpp:(.text+0xf52e): undefined reference to `ggml_cuda_host_malloc’
/usr/bin/ld: libfalcon.cpp:(.text+0xf73e): undefined reference to `ggml_cuda_assign_buffers_no_scratch’
/usr/bin/ld: libfalcon.cpp:(.text+0xf74b): undefined reference to `ggml_cuda_assign_buffers_no_scratch’
/usr/bin/ld: libfalcon.cpp:(.text+0xf7d7): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: libfalcon.cpp:(.text+0xf817): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: libfalcon.cpp:(.text+0xf88b): undefined reference to `ggml_cuda_free_data’
/usr/bin/ld: libfalcon.cpp:(.text+0xf94c): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: libfalcon.cpp:(.text+0xf97f): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: go-ggllm/libggllm.a(libfalcon.o): in function `falcon_init_from_file.cold’:
libfalcon.cpp:(.text.unlikely+0x16c8): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: libfalcon.cpp:(.text.unlikely+0x16f2): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: libfalcon.cpp:(.text.unlikely+0x1a9d): undefined reference to `ggml_cuda_free_data’
/usr/bin/ld: libfalcon.cpp:(.text.unlikely+0x1b5e): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: libfalcon.cpp:(.text.unlikely+0x1b91): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: go-ggllm/libggllm.a(libfalcon.o): in function `falcon_model::~falcon_model()’:
libfalcon.cpp:(.text._ZN12falcon_modelD2Ev[_ZN12falcon_modelD5Ev]+0x4f): undefined reference to `ggml_cuda_free_data’
/usr/bin/ld: libfalcon.cpp:(.text._ZN12falcon_modelD2Ev[_ZN12falcon_modelD5Ev]+0x10e): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: libfalcon.cpp:(.text._ZN12falcon_modelD2Ev[_ZN12falcon_modelD5Ev]+0x13d): undefined reference to `ggml_cuda_host_free’
/usr/bin/ld: go-ggllm/libggllm.a(libfalcon.o): in function `llama_model_loader::load_all_data(void (*)(float, void*, char const*), void*, llama_mlock*)’:
libfalcon.cpp:(.text._ZN18llama_model_loader13load_all_dataEPFvfPvPKcES0_P11llama_mlock[_ZN18llama_model_loader13load_all_dataEPFvfPvPKcES0_P11llama_mlock]+0x2e0): undefined reference to `ggml_cuda_transform_tensor’
/usr/bin/ld: go-ggllm/libggllm.a(libfalcon.o): in function `falcon_file_loader::read_vocab()’:
libfalcon.cpp:(.text._ZN18falcon_file_loader10read_vocabEv[_ZN18falcon_file_loader10read_vocabEv]+0x1b66): undefined reference to `ggml_init_cublas’
/usr/bin/ld: libfalcon.cpp:(.text._ZN18falcon_file_loader10read_vocabEv[_ZN18falcon_file_loader10read_vocabEv]+0x1f26): undefined reference to `ggml_init_cublas’
/usr/bin/ld: go-ggllm/libggllm.a(ggml.o): in function `ggml_init_cublas_wrapper’:
ggml.c:(.text+0x4b7b): undefined reference to `ggml_init_cublas’
/usr/bin/ld: go-ggllm/libggllm.a(ggml.o): in function `ggml_init’:
ggml.c:(.text+0x1a931): undefined reference to `ggml_init_cublas’
/usr/bin/ld: ggml.c:(.text+0x1aa19): undefined reference to `ggml_cuda_update_gpu_status’
/usr/bin/ld: go-ggllm/libggllm.a(ggml.o): in function `ggml_graph_compute_thread’:
ggml.c:(.text+0x363f8): undefined reference to `ggml_cuda_compute_forward’
/usr/bin/ld: ggml.c:(.text+0x364c7): undefined reference to `ggml_cuda_compute_forward’
/usr/bin/ld: ggml.c:(.text+0x36547): undefined reference to `ggml_cuda_compute_forward’
/usr/bin/ld: ggml.c:(.text+0x365e4): undefined reference to `ggml_cuda_compute_forward’
/usr/bin/ld: ggml.c:(.text+0x36628): undefined reference to `ggml_cuda_compute_forward’
/usr/bin/ld: go-ggllm/libggllm.a(ggml.o): in function `ggml_graph_compute’:
ggml.c:(.text+0x36a1f): undefined reference to `ggml_cuda_can_mul_mat’
/usr/bin/ld: go-ggllm/libggllm.a(falcon_common.o): in function `gpt_params_parse(int, char**, gpt_params&)’:
falcon_common.cpp:(.text+0x409c): undefined reference to `ggml_cuda_set_max_gpus’
/usr/bin/ld: falcon_common.cpp:(.text+0x569c): undefined reference to `ggml_cuda_set_main_device’
/usr/bin/ld: falcon_common.cpp:(.text+0x5722): undefined reference to `ggml_cuda_set_max_gpus’
/usr/bin/ld: falcon_common.cpp:(.text+0x579e): undefined reference to `ggml_cuda_set_vram_reserved’
/usr/bin/ld: falcon_common.cpp:(.text+0x59cc): undefined reference to `ggml_cuda_set_tensor_split_prepare’
collect2: error: ld returned 1 exit status
make: *** [Makefile:346: backend-assets/grpc/falcon] Error 2
The error messages you provided indicate that there are some unresolved references to CUDA functions in your code, specifically `ggml_cuda_host_free`, `ggml_cuda_free_data`, `ggml_cuda_get_system_gpu_status`, `ggml_cuda_pool_purge_buffers_with_access_count`, `ggml_cuda_pool_reset_all_counters`, `ggml_cuda_assign_buffers`, `ggml_cuda_set_main_device`, `ggml_cuda_update_gpu_status`, `ggml_cuda_set_scratch_size`, `ggml_cuda_transform_tensor`, `ggml_cuda_compute_forward`, `ggml_cuda_can_mul_mat`, `ggml_cuda_set_max_gpus`, `ggml_cuda_set_vram_reserved`, and `ggml_cuda_set_tensor_split_prepare`.
The issue seems to be related to missing or incorrect linking of the necessary CUDA libraries during the build process. To resolve this problem, you need to ensure that the build process correctly links against the CUDA libraries.
Here are a few steps you can take to troubleshoot and fix the issue:
1. Verify CUDA Path: Double-check that the CUDA installation path is correctly set in the `LIBRARY_PATH` and `C_INCLUDE_PATH` environment variables. Based on your previous messages, the CUDA installation path is `/usr/lib/cuda`.
2. Check Compilation Flags: Make sure that your build system (Makefile or CMake configuration) includes the correct flags to link against the CUDA libraries. Typically, you need to add `-lcudart` to link against the CUDA runtime library.
3. Check Library Location: Ensure that the CUDA library files (`libcudart.so` and other relevant libraries) are present in the CUDA installation directory (`/usr/lib/cuda`).
4. Check Library Versions: Confirm that the versions of the CUDA libraries used during the build process match the ones installed on your system. It looks like you have CUDA version 11.7 and 12.1 installed.
5. CUDA Toolkit Version: Verify that the version of the CUDA toolkit you are using to build your code matches the CUDA version required by the project.
6. CUDA Compiler: Ensure that you are using the correct version of the NVIDIA CUDA compiler (`nvcc`) that matches the CUDA version used during the build.
7. Project-specific Configurations: Check if there are any project-specific configurations or environment variables required for the successful build of the project.
By addressing these points, you should be able to resolve the issue with the unresolved references to CUDA functions and successfully build your project. If you are using a specific build system like CMake, check its configuration files for any relevant CUDA-related settings.
again, the makefile:: INCLUDE_PATH := $(abspath ./)
LIBRARY_PATH := $(abspath ./)
ifndef UNAME_S
UNAME_S := $(shell uname -s)
endif
ifndef UNAME_P
UNAME_P := $(shell uname -p)
endif
ifndef UNAME_M
UNAME_M := $(shell uname -m)
endif
CCV := $(shell $(CC) –version | head -n 1)
CXXV := $(shell $(CXX) –version | head -n 1)
# Mac OS + Arm can report x86_64
# ref: https://github.com/ggerganov/whisper.cpp/issues/66#issuecomment-1282546789
ifeq ($(UNAME_S),Darwin)
ifneq ($(UNAME_P),arm)
SYSCTL_M := $(shell sysctl -n hw.optional.arm64 2>/dev/null)
ifeq ($(SYSCTL_M),1)
# UNAME_P := arm
# UNAME_M := arm64
warn := $(warning Your arch is announced as x86_64, but it seems to actually be ARM64. Not fixing that can lead to bad performance. For more info see: https://github.com/ggerganov/whisper.cpp/issues/66#issuecomment-1282546789)
endif
endif
endif
#
# Compile flags
#
BUILD_TYPE?=
# keep standard at C11 and C++11
CFLAGS = -I./ggllm.cpp -I. -O3 -DNDEBUG -std=c11 -fPIC
CXXFLAGS = -I./ggllm.cpp -I. -I./ggllm.cpp/examples -I./examples -O3 -DNDEBUG -std=c++11 -fPIC
LDFLAGS =
# warnings
CFLAGS += -Wall -Wextra -Wpedantic -Wcast-qual -Wdouble-promotion -Wshadow -Wstrict-prototypes -Wpointer-arith -Wno-unused-function
CXXFLAGS += -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function
# OS specific
# TODO: support Windows
ifeq ($(UNAME_S),Linux)
CFLAGS += -pthread
CXXFLAGS += -pthread
endif
ifeq ($(UNAME_S),Darwin)
CFLAGS += -pthread
CXXFLAGS += -pthread
endif
ifeq ($(UNAME_S),FreeBSD)
CFLAGS += -pthread
CXXFLAGS += -pthread
endif
ifeq ($(UNAME_S),NetBSD)
CFLAGS += -pthread
CXXFLAGS += -pthread
endif
ifeq ($(UNAME_S),OpenBSD)
CFLAGS += -pthread
CXXFLAGS += -pthread
endif
ifeq ($(UNAME_S),Haiku)
CFLAGS += -pthread
CXXFLAGS += -pthread
endif
# Architecture specific
# TODO: probably these flags need to be tweaked on some architectures
# feel free to update the Makefile for your architecture and send a pull request or issue
ifeq ($(UNAME_M),$(filter $(UNAME_M),x86_64 i686))
# Use all CPU extensions that are available:
CFLAGS += -march=native -mtune=native
endif
ifneq ($(filter ppc64%,$(UNAME_M)),)
POWER9_M := $(shell grep “POWER9″ /proc/cpuinfo)
ifneq (,$(findstring POWER9,$(POWER9_M)))
CFLAGS += -mcpu=power9
CXXFLAGS += -mcpu=power9
endif
# Require c++23’s std::byteswap for big-endian support.
ifeq ($(UNAME_M),ppc64)
CXXFLAGS += -std=c++23 -DGGML_BIG_ENDIAN
endif
endif
ifndef LLAMA_NO_ACCELERATE
# Mac M1 – include Accelerate framework.
# `-framework Accelerate` works on Mac Intel as well, with negliable performance boost (as of the predict time).
ifeq ($(UNAME_S),Darwin)
CFLAGS += -DGGML_USE_ACCELERATE
LDFLAGS += -framework Accelerate
endif
endif
ifdef LLAMA_OPENBLAS
CFLAGS += -DGGML_USE_OPENBLAS -I/usr/local/include/openblas
LDFLAGS += -lopenblas
endif
ifdef LLAMA_GPROF
CFLAGS += -pg
CXXFLAGS += -pg
endif
ifneq ($(filter aarch64%,$(UNAME_M)),)
CFLAGS += -mcpu=native
CXXFLAGS += -mcpu=native
endif
ifneq ($(filter armv6%,$(UNAME_M)),)
# Raspberry Pi 1, 2, 3
CFLAGS += -mfpu=neon-fp-armv8 -mfp16-format=ieee -mno-unaligned-access
endif
ifneq ($(filter armv7%,$(UNAME_M)),)
# Raspberry Pi 4
CFLAGS += -mfpu=neon-fp-armv8 -mfp16-format=ieee -mno-unaligned-access -funsafe-math-optimizations
endif
ifneq ($(filter armv8%,$(UNAME_M)),)
# Raspberry Pi 4
CFLAGS += -mfp16-format=ieee -mno-unaligned-access
endif
ifeq ($(BUILD_TYPE),openblas)
EXTRA_LIBS=
CMAKE_ARGS+=-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS -DBLAS_INCLUDE_DIRS=/usr/include/openblas
endif
ifeq ($(BUILD_TYPE),blis)
EXTRA_LIBS=
CMAKE_ARGS+=-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=FLAME
endif
ifeq ($(BUILD_TYPE),cublas)
EXTRA_LIBS=
CMAKE_ARGS+=-DLLAMA_CUBLAS=ON
EXTRA_TARGETS+=ggllm.cpp/ggml-cuda.o
endif
ifeq ($(BUILD_TYPE),clblas)
EXTRA_LIBS=
CMAKE_ARGS+=-DLLAMA_CLBLAST=ON
EXTRA_TARGETS+=ggllm.cpp/ggml-opencl.o
endif
ifeq ($(BUILD_TYPE),metal)
EXTRA_LIBS=
CGO_LDFLAGS+=”-framework Accelerate -framework Foundation -framework Metal -framework MetalKit -framework MetalPerformanceShaders”
CMAKE_ARGS+=-DLLAMA_METAL=ON
EXTRA_TARGETS+=ggllm.cpp/ggml-metal.o
endif
ifdef CLBLAST_DIR
CMAKE_ARGS+=-DCLBlast_dir=$(CLBLAST_DIR)
endif
#
# Print build information
#
$(info I ggllm.cpp build info: )
$(info I UNAME_S: $(UNAME_S))
$(info I UNAME_P: $(UNAME_P))
$(info I UNAME_M: $(UNAME_M))
$(info I CFLAGS: $(CFLAGS))
$(info I CXXFLAGS: $(CXXFLAGS))
$(info I CGO_LDFLAGS: $(CGO_LDFLAGS))
$(info I LDFLAGS: $(LDFLAGS))
$(info I BUILD_TYPE: $(BUILD_TYPE))
$(info I CMAKE_ARGS: $(CMAKE_ARGS))
$(info I EXTRA_TARGETS: $(EXTRA_TARGETS))
$(info I CC: $(CCV))
$(info I CXX: $(CXXV))
$(info )
# Use this if you want to set the default behavior
ggllm.cpp/ggml.o: prepare
mkdir -p build
cd build && cmake ../ggllm.cpp $(CMAKE_ARGS) && VERBOSE=1 cmake –build . –config Release && cp -rf CMakeFiles/ggml.dir/ggml.c.o ../ggllm.cpp/ggml.o
ggllm.cpp/ggml-cuda.o: ggllm.cpp/ggml.o
cd build && cp -rf CMakeFiles/ggml.dir/ggml-cuda.cu.o ../ggllm.cpp/ggml-cuda.o
ggllm.cpp/ggml-opencl.o: ggllm.cpp/ggml.o
cd build && cp -rf CMakeFiles/ggml.dir/ggml-opencl.cpp.o ../ggllm.cpp/ggml-opencl.o
ggllm.cpp/ggml-metal.o: ggllm.cpp/ggml.o
cd build && cp -rf CMakeFiles/ggml.dir/ggml-metal.m.o ../ggllm.cpp/ggml-metal.o
ggllm.cpp/k_quants.o: ggllm.cpp/ggml.o
cd build && cp -rf CMakeFiles/ggml.dir/k_quants.c.o ../ggllm.cpp/k_quants.o
ggllm.cpp/llama.o:
cd build && cp -rf CMakeFiles/llama.dir/llama.cpp.o ../ggllm.cpp/llama.o
ggllm.cpp/libfalcon.o:
cd build && cp -rf CMakeFiles/falcon.dir/libfalcon.cpp.o ../ggllm.cpp/libfalcon.o
ggllm.cpp/falcon_common.o:
cd build && cp -rf examples/CMakeFiles/falcon_common.dir/falcon_common.cpp.o ../ggllm.cpp/falcon_common.o
ggllm.cpp/cmpnct_unicode.o:
cd build && cp -rf CMakeFiles/cmpnct_unicode.dir/cmpnct_unicode.cpp.o ../ggllm.cpp/cmpnct_unicode.o
falcon_binding.o: prepare ggllm.cpp/ggml.o ggllm.cpp/cmpnct_unicode.o ggllm.cpp/llama.o ggllm.cpp/libfalcon.o ggllm.cpp/falcon_common.o
$(CXX) $(CXXFLAGS) -I./ggllm.cpp -I./ggllm.cpp/examples falcon_binding.cpp -o falcon_binding.o -c $(LDFLAGS)
## https://github.com/ggerganov/llama.cpp/pull/1902
prepare:
cd ggllm.cpp && patch -p1 < ../patches/1902-cuda.patch
touch $@
libggllm.a: prepare falcon_binding.o ggllm.cpp/k_quants.o $(EXTRA_TARGETS)
ar src libggllm.a ggllm.cpp/libfalcon.o ggllm.cpp/cmpnct_unicode.o ggllm.cpp/ggml.o ggllm.cpp/k_quants.o $(EXTRA_TARGETS) ggllm.cpp/falcon_common.o falcon_binding.o
clean:
rm -rf *.o
rm -rf *.a
$(MAKE) -C ggllm.cpp clean
rm -rf build
test: libggllm.a
@C_INCLUDE_PATH=${INCLUDE_PATH} CGO_LDFLAGS=${CGO_LDFLAGS} LIBRARY_PATH=${LIBRARY_PATH} go test -v ./…
Based on the provided Makefile, it seems that the build process involves several steps to compile and link the `libggllm.a` static library, and then it proceeds to build a Go project using that library (`falcon_binding.o`). The error messages you provided earlier indicate that there are unresolved references to CUDA functions when building the `libggllm.a` library.
To address the issue, you need to ensure that CUDA is correctly linked when building the `libggllm.a` library. Since there are multiple build types (`cublas`, `clblas`, `metal`, etc.), the linking and compilation flags might vary depending on the selected build type.
You mentioned that the libraries are installed in `/usr/lib/cuda`, so you need to make sure that the correct CUDA library paths are set during the build process. Specifically, you should ensure that the CUDA libraries are added to the `LIBRARY_PATH` and `CGO_LDFLAGS` variables when building the `libggllm.a` library.
Here are the steps you can take to fix the issue:
1. Update `LIBRARY_PATH` and `CGO_LDFLAGS`: Modify the Makefile to include the correct CUDA library paths (`/usr/lib/cuda/lib64`) in the `LIBRARY_PATH` and `CGO_LDFLAGS` variables. You can do this by adding the appropriate flags to the respective lines in the Makefile.
2. Check Build Type: Depending on the build type (`cublas`, `clblas`, etc.) you want to use, make sure the corresponding CUDA-related flags are set appropriately. For example, if you are building with `cublas`, make sure the `CMAKE_ARGS` variable includes `-DLLAMA_CUBLAS=ON`.
3. CUDA Headers: Additionally, if your project depends on CUDA header files (`cublas.h`, etc.), ensure that the CUDA include path is included in the `CXXFLAGS` variable. You can do this by adding `-I/usr/lib/cuda/include` or the appropriate path to the CUDA headers.
4. Verify Other Dependencies: Double-check if there are any other dependencies (e.g., OpenBLAS) required for the build, and ensure they are correctly linked and included.
After making these modifications to the Makefile, try running the build process again. If everything is set up correctly, the unresolved references to CUDA functions should be resolved, and the build should succeed without any issues.
Note: Make sure to save a backup of the original Makefile before making any changes, so you can revert if needed. Also, be cautious when modifying Makefiles, as they can be sensitive to formatting and indentation.
# Use this if you want to set the default behavior
ggllm.cpp/ggml.o: prepare
mkdir -p build
cd build && cmake ../ggllm.cpp $(CMAKE_ARGS) && VERBOSE=1 cmake –build . –config Release && cp -rf CMakeFiles/ggml.dir/ggml.c.o ../ggllm.cpp/ggml.o
ggllm.cpp/ggml-cuda.o: ggllm.cpp/ggml.o
cd build && cp -rf CMakeFiles/ggml.dir/ggml-cuda.cu.o ../ggllm.cpp/ggml-cuda.o
ggllm.cpp/ggml-opencl.o: ggllm.cpp/ggml.o
cd build && cp -rf CMakeFiles/ggml.dir/ggml-opencl.cpp.o ../ggllm.cpp/ggml-opencl.o
ggllm.cpp/ggml-metal.o: ggllm.cpp/ggml.o
cd build && cp -rf CMakeFiles/ggml.dir/ggml-metal.m.o ../ggllm.cpp/ggml-metal.o
ggllm.cpp/k_quants.o: ggllm.cpp/ggml.o
cd build && cp -rf CMakeFiles/ggml.dir/k_quants.c.o ../ggllm.cpp/k_quants.o
ggllm.cpp/llama.o:
cd build && cp -rf CMakeFiles/llama.dir/llama.cpp.o ../ggllm.cpp/llama.o
ggllm.cpp/libfalcon.o:
cd build && cp -rf CMakeFiles/falcon.dir/libfalcon.cpp.o ../ggllm.cpp/libfalcon.o
ggllm.cpp/falcon_common.o:
cd build && cp -rf examples/CMakeFiles/falcon_common.dir/falcon_common.cpp.o ../ggllm.cpp/falcon_common.o
ggllm.cpp/cmpnct_unicode.o:
cd build && cp -rf CMakeFiles/cmpnct_unicode.dir/cmpnct_unicode.cpp.o ../ggllm.cpp/cmpnct_unicode.o
falcon_binding.o: prepare ggllm.cpp/ggml.o ggllm.cpp/cmpnct_unicode.o ggllm.cpp/llama.o ggllm.cpp/libfalcon.o ggllm.cpp/falcon_common.o
$(CXX) $(CXXFLAGS) -I./ggllm.cpp -I./ggllm.cpp/examples falcon_binding.cpp -o falcon_binding.o -c $(LDFLAGS)
Thank you for providing more details about the build process. Based on the updated information, it appears that the Makefile contains rules to compile and link various object files (`*.o`) required for building the `libggllm.a` library.
Given that there are different build types (`cublas`, `clblas`, `metal`, etc.) and corresponding rules for each, the issue with unresolved references to CUDA functions may arise from not selecting the correct build type or not setting the necessary CUDA-related flags during the build process.
Here's what you can do to address the issue:
1. Choose the correct build type: Depending on your system and requirements, select the appropriate build type (e.g., `cublas`, `clblas`, etc.) and set it as the `BUILD_TYPE` variable. You can do this by adding the desired build type to the `BUILD_TYPE?=…` line at the beginning of the Makefile.
2. Ensure CUDA-related flags are set: Check the rules for the respective build types (`ggllm.cpp/ggml-cuda.o`, `ggllm.cpp/ggml-opencl.o`, etc.) and verify that they include the necessary CUDA-related flags. For example, for the `ggllm.cpp/ggml-cuda.o` rule, ensure that it includes `-DLLAMA_CUBLAS=ON` in the `CMAKE_ARGS` variable.
3. Verify other dependencies: Double-check if there are any other dependencies required for the build, such as OpenBLAS or other CUDA-related libraries, and ensure they are correctly linked and included.
4. Run the build process: After making the necessary modifications to the Makefile, run the build process again to see if the issue is resolved.
Here's an example of how the beginning of the Makefile might look with the `BUILD_TYPE` variable set to `cublas`:
“`make
# …
# Set the default build type (e.g., cublas)
BUILD_TYPE?=cublas
# …
ggllm.cpp/ggml-cuda.o: ggllm.cpp/ggml.o
cd build && cp -rf CMakeFiles/ggml.dir/ggml-cuda.cu.o ../ggllm.cpp/ggml-cuda.o
# Set other build rules for different build types here…
# …
“`
Remember to save a backup of the original Makefile before making any changes, and be cautious when modifying Makefiles, as they can be sensitive to formatting and indentation.
If you encounter any other issues or have further questions, feel free to ask. Good luck with your build!
export BUILD_TYPE?=
CGO_LDFLAGS?=
CUDA_LIBPATH?=/usr/local/cuda/lib64/
GO_TAGS?=
BUILD_ID?=git
It looks like you're setting some environment variables that will be used during the build process. Let's go through each of them to understand their purpose:
1. `BUILD_TYPE`: This variable is used to specify the build type, such as `cublas`, `clblas`, `metal`, etc., depending on the supported accelerators. As mentioned earlier, you should set it to the desired build type (e.g., `BUILD_TYPE=cublas`) to ensure the correct dependencies are used during the build.
2. `CGO_LDFLAGS`: This environment variable is used to pass linker flags to the Go compiler when building CGo (Go code that calls C or C++ code). It can be used to specify additional libraries or library paths required during the linking process. In your case, it seems that this variable is left empty (`CGO_LDFLAGS=`), which means no additional linker flags are explicitly specified.
3. `CUDA_LIBPATH`: This variable points to the directory containing the CUDA libraries. In your case, it's set to `/usr/local/cuda/lib64/`, which is the default path for CUDA libraries on some systems. This path is used during the linking phase to find and link the CUDA-related functions.
4. `GO_TAGS`: This variable is used to specify Go build tags. Build tags allow conditional compilation of Go code based on build constraints, such as the operating system or architecture. If you have specific build tags defined in your Go code, you can set them using this variable.
5. `BUILD_ID`: This variable specifies the build identifier, which is often used to label builds with a version or commit information. In your case, it's set to `git`, indicating that the build ID should be extracted from the Git repository.
Remember that environment variables set during the build process can affect the outcome, so it's essential to ensure they are set correctly based on your system and requirements.
If you have any specific questions about any of these variables or need further assistance with the build process, please let me know!
export BUILD_TYPE?=cublas
CGO_LDFLAGS?=
CUDA_LIBPATH?=/usr/lib/cuda/lib64/
GO_TAGS?=stablediffusion
BUILD_ID?=git
Great! Now you have set the environment variables for the build process. Let's go through them again:
1. `BUILD_TYPE=cublas`: You've set the build type to `cublas`, which means you want to use NVIDIA cuBLAS library for GPU acceleration.
2. `CGO_LDFLAGS=`: The `CGO_LDFLAGS` variable is left empty, which means no additional linker flags are explicitly specified.
3. `CUDA_LIBPATH=/usr/lib/cuda/lib64/`: You've specified the path to the CUDA libraries. It's set to `/usr/lib/cuda/lib64/`, which is the directory containing the CUDA libraries. Note that the path may vary based on your CUDA installation.
4. `GO_TAGS=stablediffusion`: You've set the Go build tags to `stablediffusion`. Build tags allow conditional compilation of Go code based on certain constraints. In this case, it seems to enable some features or optimizations related to stable diffusion.
5. `BUILD_ID=git`: You've set the build identifier to `git`, which indicates that the build ID should be extracted from the Git repository. This is commonly used to include version or commit information in the build.
With these environment variables set, you are now ready to proceed with the build process. Make sure to execute the appropriate commands, such as `make` or `go build`, with these environment variables in scope to ensure the correct configuration and dependencies are used.
If you encounter any issues or need further assistance during the build process, feel free to ask for help!
what is this ESPEAK_DATA that is availabel
The `ESPEAK_DATA` environment variable is related to the eSpeak Text-to-Speech (TTS) engine. eSpeak is an open-source software speech synthesizer that can convert text into spoken words. The `ESPEAK_DATA` variable is used to specify the path to the eSpeak data files, which include the language data and phoneme files required for text-to-speech processing in different languages.
When eSpeak is installed on a system, it typically comes with language-specific data files stored in a specific directory. The `ESPEAK_DATA` variable allows you to point to this directory so that eSpeak can locate the necessary data when performing text-to-speech synthesis.
Setting the `ESPEAK_DATA` variable is not always necessary, as eSpeak can often find its data files automatically. However, in certain cases, especially when eSpeak is not installed in a standard location, or if you want to use custom language data files, setting this environment variable can be helpful.
If you are using eSpeak or a program that relies on it for TTS, and you are encountering issues related to missing language data, specifying the `ESPEAK_DATA` variable with the correct path to the data files may resolve the problem.
ar src libtransformers.a replit.o gptj.o mpt.o gptneox.o starcoder.o gpt2.o dolly.o falcon.o ggml.o common-ggml.o common.o ggml-cuda.o
ar: ggml-cuda.o: No such file or directory
make[1]: *** [Makefile:206: libtransformers.a] Error 1
make[1]: Leaving directory '/mnt/c/SarahOne/SuperAgi/app/localai/go-ggml-transformers'
make: *** [Makefile:182: go-ggml-transformers/libtransformers.a] Error 2
(base) gemini@DESKTOP-UNG8TH9:/mnt/c/SarahOne/SuperAgi/app/localai$
The error message indicates that the build process is trying to use the file `ggml-cuda.o` to create the static library `libtransformers.a`, but it cannot find the `ggml-cuda.o` file. As a result, the build fails with an "No such file or directory" error.
There are a few possible reasons for this error:
1. Missing Source File: The `ggml-cuda.o` file is expected to be one of the object files used in the library, but it seems that it is missing. Make sure that the file `ggml-cuda.o` exists in the correct location and has been compiled successfully. Check if there were any errors during the compilation process of this specific file.
2. Incorrect Build Process: It's possible that the build process is not properly generating the `ggml-cuda.o` file. Double-check the build commands and the makefile rules to ensure that `ggml-cuda.o` is being compiled and linked correctly.
3. Incorrect File Path: If the `ggml-cuda.o` file exists but is located in a different directory than where the build process is expecting it, you may encounter this error. Ensure that the correct file path is specified in the makefile or build script.
4. Dependency Issues: The build process might have dependencies on other components that are not properly set up. Make sure that all required dependencies, including CUDA libraries and headers, are installed and accessible.
To troubleshoot the issue further, examine the makefile or build script to see how `ggml-cuda.o` is being generated and used in the build process. Also, check the build log for any error messages related to the compilation of `ggml-cuda.o`. Additionally, verify that all required dependencies and files are present in the expected locations.
If you are not familiar with the build process or the project structure, consider seeking assistance from someone who is experienced in building and configuring such projects, as it may involve complex interactions between different components.
GOCMD=go
GOTEST=$(GOCMD) test
GOVET=$(GOCMD) vet
BINARY_NAME=local-ai
# llama.cpp versions
GOLLAMA_VERSION?=8c51308e42d79e8de2553747b23e74f444b02ae2
# gpt4all version
GPT4ALL_REPO?=https://github.com/nomic-ai/gpt4all
GPT4ALL_VERSION?=91a32c0e84a091ce7e0a3c4d08a058c75c770306
# go-ggml-transformers version
GOGGMLTRANSFORMERS_VERSION?=ffb09d7dd71e2cbc6c5d7d05357d230eea6f369a
# go-rwkv version
RWKV_REPO?=https://github.com/donomii/go-rwkv.cpp
RWKV_VERSION?=c898cd0f62df8f2a7830e53d1d513bef4f6f792b
# whisper.cpp version
WHISPER_CPP_VERSION?=85ed71aaec8e0612a84c0b67804bde75aa75a273
# bert.cpp version
BERT_VERSION?=6abe312cded14042f6b7c3cd8edf082713334a4d
# go-piper version
PIPER_VERSION?=56b8a81b4760a6fbee1a82e62f007ae7e8f010a7
# go-bloomz version
BLOOMZ_VERSION?=1834e77b83faafe912ad4092ccf7f77937349e2f
# stablediffusion version
STABLEDIFFUSION_VERSION?=d89260f598afb809279bc72aa0107b4292587632
# Go-ggllm
GOGGLLM_VERSION?=862477d16eefb0805261c19c9b0d053e3b2b684b
export BUILD_TYPE?=cublas
CGO_LDFLAGS?=
CUDA_LIBPATH?=/usr/lib/cuda/lib64/
GO_TAGS?=stablediffusion
BUILD_ID?=git
VERSION?=$(shell git describe –always –tags || echo "dev" )
# go tool nm ./local-ai | grep Commit
LD_FLAGS?=
override LD_FLAGS += -X "github.com/go-skynet/LocalAI/internal.Version=$(VERSION)"
override LD_FLAGS += -X "github.com/go-skynet/LocalAI/internal.Commit=$(shell git rev-parse HEAD)"
OPTIONAL_TARGETS?=
ESPEAK_DATA?=
OS := $(shell uname -s)
ARCH := $(shell uname -m)
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
CYAN := $(shell tput -Txterm setaf 6)
RESET := $(shell tput -Txterm sgr0)
ifndef UNAME_S
UNAME_S := $(shell uname -s)
endif
# workaround for rwkv.cpp
ifeq ($(UNAME_S),Darwin)
CGO_LDFLAGS += -lcblas -framework Accelerate
endif
ifeq ($(BUILD_TYPE),openblas)
CGO_LDFLAGS+=-lopenblas
endif
ifeq ($(BUILD_TYPE),cublas)
CGO_LDFLAGS+=-lcublas -lcudart -L$(CUDA_LIBPATH)
export LLAMA_CUBLAS=1
endif
ifeq ($(BUILD_TYPE),metal)
CGO_LDFLAGS+=-framework Foundation -framework Metal -framework MetalKit -framework MetalPerformanceShaders
export LLAMA_METAL=1
endif
ifeq ($(BUILD_TYPE),clblas)
CGO_LDFLAGS+=-lOpenCL -lclblast
endif
# glibc-static or glibc-devel-static required
ifeq ($(STATIC),true)
LD_FLAGS=-linkmode external -extldflags -static
endif
ifeq ($(findstring stablediffusion,$(GO_TAGS)),stablediffusion)
# OPTIONAL_TARGETS+=go-stable-diffusion/libstablediffusion.a
OPTIONAL_GRPC+=backend-assets/grpc/stablediffusion
endif
ifeq ($(findstring tts,$(GO_TAGS)),tts)
# OPTIONAL_TARGETS+=go-piper/libpiper_binding.a
# OPTIONAL_TARGETS+=backend-assets/espeak-ng-data
OPTIONAL_GRPC+=backend-assets/grpc/piper
endif
.PHONY: all test build vendor
all: help
## GPT4ALL
gpt4all:
git clone –recurse-submodules $(GPT4ALL_REPO) gpt4all
cd gpt4all && git checkout -b build $(GPT4ALL_VERSION) && git submodule update –init –recursive –depth 1
## go-ggllm
go-ggllm:
git clone –recurse-submodules https://github.com/mudler/go-ggllm.cpp go-ggllm
cd go-ggllm && git checkout -b build $(GOGGLLM_VERSION) && git submodule update –init –recursive –depth 1
go-ggllm/libggllm.a: go-ggllm
$(MAKE) -C go-ggllm BUILD_TYPE=$(BUILD_TYPE) libggllm.a
## go-piper
go-piper:
git clone –recurse-submodules https://github.com/mudler/go-piper go-piper
cd go-piper && git checkout -b build $(PIPER_VERSION) && git submodule update –init –recursive –depth 1
## BERT embeddings
go-bert:
git clone –recurse-submodules https://github.com/go-skynet/go-bert.cpp go-bert
cd go-bert && git checkout -b build $(BERT_VERSION) && git submodule update –init –recursive –depth 1
## stable diffusion
go-stable-diffusion:
git clone –recurse-submodules https://github.com/mudler/go-stable-diffusion go-stable-diffusion
cd go-stable-diffusion && git checkout -b build $(STABLEDIFFUSION_VERSION) && git submodule update –init –recursive –depth 1
go-stable-diffusion/libstablediffusion.a:
$(MAKE) -C go-stable-diffusion libstablediffusion.a
## RWKV
go-rwkv:
git clone –recurse-submodules $(RWKV_REPO) go-rwkv
cd go-rwkv && git checkout -b build $(RWKV_VERSION) && git submodule update –init –recursive –depth 1
go-rwkv/librwkv.a: go-rwkv
cd go-rwkv && cd rwkv.cpp && cmake . -DRWKV_BUILD_SHARED_LIBRARY=OFF && cmake –build . && cp librwkv.a ..
## bloomz
bloomz:
git clone –recurse-submodules https://github.com/go-skynet/bloomz.cpp bloomz
cd bloomz && git checkout -b build $(BLOOMZ_VERSION) && git submodule update –init –recursive –depth 1
bloomz/libbloomz.a: bloomz
cd bloomz && make libbloomz.a
go-bert/libgobert.a: go-bert
$(MAKE) -C go-bert libgobert.a
backend-assets/gpt4all: gpt4all/gpt4all-bindings/golang/libgpt4all.a
mkdir -p backend-assets/gpt4all
@cp gpt4all/gpt4all-bindings/golang/buildllm/*.so backend-assets/gpt4all/ || true
@cp gpt4all/gpt4all-bindings/golang/buildllm/*.dylib backend-assets/gpt4all/ || true
@cp gpt4all/gpt4all-bindings/golang/buildllm/*.dll backend-assets/gpt4all/ || true
backend-assets/espeak-ng-data:
mkdir -p backend-assets/espeak-ng-data
ifdef ESPEAK_DATA
@cp -rf $(ESPEAK_DATA)/. backend-assets/espeak-ng-data
else
@echo "ESPEAK_DATA not set, skipping tts. Note that this will break the tts functionality."
@touch backend-assets/espeak-ng-data/keep
endif
gpt4all/gpt4all-bindings/golang/libgpt4all.a: gpt4all
$(MAKE) -C gpt4all/gpt4all-bindings/golang/ libgpt4all.a
## CEREBRAS GPT
go-ggml-transformers:
git clone –recurse-submodules https://github.com/go-skynet/go-ggml-transformers.cpp go-ggml-transformers
cd go-ggml-transformers && git checkout -b build $(GOGPT2_VERSION) && git submodule update –init –recursive –depth 1
go-ggml-transformers/libtransformers.a: go-ggml-transformers
$(MAKE) -C go-ggml-transformers BUILD_TYPE=$(BUILD_TYPE) libtransformers.a
whisper.cpp:
git clone https://github.com/ggerganov/whisper.cpp.git
cd whisper.cpp && git checkout -b build $(WHISPER_CPP_VERSION) && git submodule update –init –recursive –depth 1
whisper.cpp/libwhisper.a: whisper.cpp
cd whisper.cpp && make libwhisper.a
go-llama:
git clone –recurse-submodules https://github.com/go-skynet/go-llama.cpp go-llama
cd go-llama && git checkout -b build $(GOLLAMA_VERSION) && git submodule update –init –recursive –depth 1
go-llama/libbinding.a: go-llama
$(MAKE) -C go-llama BUILD_TYPE=$(BUILD_TYPE) libbinding.a
go-piper/libpiper_binding.a:
$(MAKE) -C go-piper libpiper_binding.a example/main
get-sources: go-llama go-ggllm go-ggml-transformers gpt4all go-piper go-rwkv whisper.cpp go-bert bloomz go-stable-diffusion
touch $@
replace:
$(GOCMD) mod edit -replace github.com/go-skynet/go-llama.cpp=$(shell pwd)/go-llama
$(GOCMD) mod edit -replace github.com/nomic-ai/gpt4all/gpt4all-bindings/golang=$(shell pwd)/gpt4all/gpt4all-bindings/golang
$(GOCMD) mod edit -replace github.com/go-skynet/go-ggml-transformers.cpp=$(shell pwd)/go-ggml-transformers
$(GOCMD) mod edit -replace github.com/donomii/go-rwkv.cpp=$(shell pwd)/go-rwkv
$(GOCMD) mod edit -replace github.com/ggerganov/whisper.cpp=$(shell pwd)/whisper.cpp
$(GOCMD) mod edit -replace github.com/go-skynet/go-bert.cpp=$(shell pwd)/go-bert
$(GOCMD) mod edit -replace github.com/go-skynet/bloomz.cpp=$(shell pwd)/bloomz
$(GOCMD) mod edit -replace github.com/mudler/go-stable-diffusion=$(shell pwd)/go-stable-diffusion
$(GOCMD) mod edit -replace github.com/mudler/go-piper=$(shell pwd)/go-piper
$(GOCMD) mod edit -replace github.com/mudler/go-ggllm.cpp=$(shell pwd)/go-ggllm
prepare-sources: get-sources replace
$(GOCMD) mod download
## GENERIC
rebuild: ## Rebuilds the project
$(GOCMD) clean -cache
$(MAKE) -C go-llama clean
$(MAKE) -C gpt4all/gpt4all-bindings/golang/ clean
$(MAKE) -C go-ggml-transformers clean
$(MAKE) -C go-rwkv clean
$(MAKE) -C whisper.cpp clean
$(MAKE) -C go-stable-diffusion clean
$(MAKE) -C go-bert clean
$(MAKE) -C bloomz clean
$(MAKE) -C go-piper clean
$(MAKE) -C go-ggllm clean
$(MAKE) build
prepare: prepare-sources $(OPTIONAL_TARGETS)
touch $@
clean: ## Remove build related file
$(GOCMD) clean -cache
rm -f prepare
rm -rf ./go-llama
rm -rf ./gpt4all
rm -rf ./go-gpt2
rm -rf ./go-stable-diffusion
rm -rf ./go-ggml-transformers
rm -rf ./backend-assets
rm -rf ./go-rwkv
rm -rf ./go-bert
rm -rf ./bloomz
rm -rf ./whisper.cpp
rm -rf ./go-piper
rm -rf ./go-ggllm
rm -rf $(BINARY_NAME)
rm -rf release/
## Build:
build: grpcs prepare ## Build the project
$(info ${GREEN}I local-ai build info:${RESET})
$(info ${GREEN}I BUILD_TYPE: ${YELLOW}$(BUILD_TYPE)${RESET})
$(info ${GREEN}I GO_TAGS: ${YELLOW}$(GO_TAGS)${RESET})
$(info ${GREEN}I LD_FLAGS: ${YELLOW}$(LD_FLAGS)${RESET})
CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o $(BINARY_NAME) ./
dist: build
mkdir -p release
cp $(BINARY_NAME) release/$(BINARY_NAME)-$(BUILD_ID)-$(OS)-$(ARCH)
## Run
run: prepare ## run local-ai
CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GOCMD) run ./
test-models/testmodel:
mkdir test-models
mkdir test-dir
wget https://huggingface.co/nnakasato/ggml-model-test/resolve/main/ggml-model-q4.bin -O test-models/testmodel
wget https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base.en.bin -O test-models/whisper-en
wget https://huggingface.co/skeskinen/ggml/resolve/main/all-MiniLM-L6-v2/ggml-model-q4_0.bin -O test-models/bert
wget https://cdn.openai.com/whisper/draft-20220913a/micro-machines.wav -O test-dir/audio.wav
wget https://huggingface.co/mudler/rwkv-4-raven-1.5B-ggml/resolve/main/RWKV-4-Raven-1B5-v11-Eng99%2525-Other1%2525-20230425-ctx4096_Q4_0.bin -O test-models/rwkv
wget https://raw.githubusercontent.com/saharNooby/rwkv.cpp/5eb8f09c146ea8124633ab041d9ea0b1f1db4459/rwkv/20B_tokenizer.json -O test-models/rwkv.tokenizer.json
cp tests/models_fixtures/* test-models
prepare-test: grpcs
cp -rf backend-assets api
cp tests/models_fixtures/* test-models
test: prepare test-models/testmodel grpcs
@echo 'Running tests'
export GO_TAGS="tts stablediffusion"
$(MAKE) prepare-test
HUGGINGFACE_GRPC=$(abspath ./)/extra/grpc/huggingface/huggingface.py TEST_DIR=$(abspath ./)/test-dir/ FIXTURES=$(abspath ./)/tests/fixtures CONFIG_FILE=$(abspath ./)/test-models/config.yaml MODELS_PATH=$(abspath ./)/test-models
$(GOCMD) run github.com/onsi/ginkgo/v2/ginkgo –label-filter="!gpt4all && !llama" –flake-attempts 5 -v -r ./api ./pkg
$(MAKE) test-gpt4all
$(MAKE) test-llama
$(MAKE) test-tts
$(MAKE) test-stablediffusion
test-gpt4all: prepare-test
TEST_DIR=$(abspath ./)/test-dir/ FIXTURES=$(abspath ./)/tests/fixtures CONFIG_FILE=$(abspath ./)/test-models/config.yaml MODELS_PATH=$(abspath ./)/test-models
$(GOCMD) run github.com/onsi/ginkgo/v2/ginkgo –label-filter="gpt4all" –flake-attempts 5 -v -r ./api ./pkg
test-llama: prepare-test
TEST_DIR=$(abspath ./)/test-dir/ FIXTURES=$(abspath ./)/tests/fixtures CONFIG_FILE=$(abspath ./)/test-models/config.yaml MODELS_PATH=$(abspath ./)/test-models
$(GOCMD) run github.com/onsi/ginkgo/v2/ginkgo –label-filter="llama" –flake-attempts 5 -v -r ./api ./pkg
test-tts: prepare-test
TEST_DIR=$(abspath ./)/test-dir/ FIXTURES=$(abspath ./)/tests/fixtures CONFIG_FILE=$(abspath ./)/test-models/config.yaml MODELS_PATH=$(abspath ./)/test-models
$(GOCMD) run github.com/onsi/ginkgo/v2/ginkgo –label-filter="tts" –flake-attempts 1 -v -r ./api ./pkg
test-stablediffusion: prepare-test
TEST_DIR=$(abspath ./)/test-dir/ FIXTURES=$(abspath ./)/tests/fixtures CONFIG_FILE=$(abspath ./)/test-models/config.yaml MODELS_PATH=$(abspath ./)/test-models
$(GOCMD) run github.com/onsi/ginkgo/v2/ginkgo –label-filter="stablediffusion" –flake-attempts 1 -v -r ./api ./pkg
test-container:
docker build –target requirements -t local-ai-test-container .
docker run -ti –rm –entrypoint /bin/bash -ti -v $(abspath ./):/build local-ai-test-container
## Help:
help: ## Show this help.
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}${RESET}’
@echo ”
@echo ‘Targets:’
@awk ‘BEGIN {FS = “:.*?## “} {
if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf ” ${YELLOW}%-20s${GREEN}%s${RESET}n”, $$1, $$2}
else if (/^## .*$$/) {printf ” ${CYAN}%s${RESET}n”, substr($$1,4)}
}’ $(MAKEFILE_LIST)
protogen: protogen-go protogen-python
protogen-go:
protoc –go_out=. –go_opt=paths=source_relative –go-grpc_out=. –go-grpc_opt=paths=source_relative
pkg/grpc/proto/backend.proto
protogen-python:
python -m grpc_tools.protoc -Ipkg/grpc/proto/ –python_out=extra/grpc/huggingface/ –grpc_python_out=extra/grpc/huggingface/ pkg/grpc/proto/backend.proto
## GRPC
backend-assets/grpc:
mkdir -p backend-assets/grpc
backend-assets/grpc/falcon: backend-assets/grpc go-ggllm/libggllm.a
CGO_LDFLAGS=”$(CGO_LDFLAGS)” C_INCLUDE_PATH=$(shell pwd)/go-ggllm LIBRARY_PATH=$(shell pwd)/go-ggllm
$(GOCMD) build -ldflags “$(LD_FLAGS)” -tags “$(GO_TAGS)” -o backend-assets/grpc/falcon ./cmd/grpc/falcon/
backend-assets/grpc/llama: backend-assets/grpc go-llama/libbinding.a
CGO_LDFLAGS=”$(CGO_LDFLAGS)” C_INCLUDE_PATH=$(shell pwd)/go-llama LIBRARY_PATH=$(shell pwd)/go-llama
$(GOCMD) build -ldflags “$(LD_FLAGS)” -tags “$(GO_TAGS)” -o backend-assets/grpc/llama ./cmd/grpc/llama/
# TODO: every binary should have its own folder instead, so can have different metal implementations
ifeq ($(BUILD_TYPE),metal)
cp go-llama/build/bin/ggml-metal.metal backend-assets/grpc/
endif
backend-assets/grpc/gpt4all: backend-assets/grpc backend-assets/gpt4all gpt4all/gpt4all-bindings/golang/libgpt4all.a
CGO_LDFLAGS=”$(CGO_LDFLAGS)” C_INCLUDE_PATH=$(shell pwd)/gpt4all/gpt4all-bindings/golang/ LIBRARY_PATH=$(shell pwd)/gpt4all/gpt4all-bindings/golang/
$(GOCMD) build -ldflags “$(LD_FLAGS)” -tags “$(GO_TAGS)” -o backend-assets/grpc/gpt4all ./cmd/grpc/gpt4all/
backend-assets/grpc/dolly: backend-assets/grpc go-ggml-transformers/libtransformers.a
CGO_LDFLAGS=”$(CGO_LDFLAGS)” C_INCLUDE_PATH=$(shell pwd)/go-ggml-transformers LIBRARY_PATH=$(shell pwd)/go-ggml-transformers
$(GOCMD) build -ldflags “$(LD_FLAGS)” -tags “$(GO_TAGS)” -o backend-assets/grpc/dolly ./cmd/grpc/dolly/
backend-assets/grpc/gpt2: backend-assets/grpc go-ggml-transformers/libtransformers.a
CGO_LDFLAGS=”$(CGO_LDFLAGS)” C_INCLUDE_PATH=$(shell pwd)/go-ggml-transformers LIBRARY_PATH=$(shell pwd)/go-ggml-transformers
$(GOCMD) build -ldflags “$(LD_FLAGS)” -tags “$(GO_TAGS)” -o backend-assets/grpc/gpt2 ./cmd/grpc/gpt2/
backend-assets/grpc/gptj: backend-assets/grpc go-ggml-transformers/libtransformers.a
CGO_LDFLAGS=”$(CGO_LDFLAGS)” C_INCLUDE_PATH=$(shell pwd)/go-ggml-transformers LIBRARY_PATH=$(shell pwd)/go-ggml-transformers
$(GOCMD) build -ldflags “$(LD_FLAGS)” -tags “$(GO_TAGS)” -o backend-assets/grpc/gptj ./cmd/grpc/gptj/
backend-assets/grpc/gptneox: backend-assets/grpc go-ggml-transformers/libtransformers.a
CGO_LDFLAGS=”$(CGO_LDFLAGS)” C_INCLUDE_PATH=$(shell pwd)/go-ggml-transformers LIBRARY_PATH=$(shell pwd)/go-ggml-transformers
$(GOCMD) build -ldflags “$(LD_FLAGS)” -tags “$(GO_TAGS)” -o backend-assets/grpc/gptneox ./cmd/grpc/gptneox/
backend-assets/grpc/mpt: backend-assets/grpc go-ggml-transformers/libtransformers.a
CGO_LDFLAGS=”$(CGO_LDFLAGS)” C_INCLUDE_PATH=$(shell pwd)/go-ggml-transformers LIBRARY_PATH=$(shell pwd)/go-ggml-transformers
$(GOCMD) build -ldflags “$(LD_FLAGS)” -tags “$(GO_TAGS)” -o backend-assets/grpc/mpt ./cmd/grpc/mpt/
backend-assets/grpc/replit: backend-assets/grpc go-ggml-transformers/libtransformers.a
CGO_LDFLAGS=”$(CGO_LDFLAGS)” C_INCLUDE_PATH=$(shell pwd)/go-ggml-transformers LIBRARY_PATH=$(shell pwd)/go-ggml-transformers
$(GOCMD) build -ldflags “$(LD_FLAGS)” -tags “$(GO_TAGS)” -o backend-assets/grpc/replit ./cmd/grpc/replit/
backend-assets/grpc/falcon-ggml: backend-assets/grpc go-ggml-transformers/libtransformers.a
CGO_LDFLAGS=”$(CGO_LDFLAGS)” C_INCLUDE_PATH=$(shell pwd)/go-ggml-transformers LIBRARY_PATH=$(shell pwd)/go-ggml-transformers
$(GOCMD) build -ldflags “$(LD_FLAGS)” -tags “$(GO_TAGS)” -o backend-assets/grpc/falcon-ggml ./cmd/grpc/falcon-ggml/
backend-assets/grpc/starcoder: backend-assets/grpc go-ggml-transformers/libtransformers.a
CGO_LDFLAGS=”$(CGO_LDFLAGS)” C_INCLUDE_PATH=$(shell pwd)/go-ggml-transformers LIBRARY_PATH=$(shell pwd)/go-ggml-transformers
$(GOCMD) build -ldflags “$(LD_FLAGS)” -tags “$(GO_TAGS)” -o backend-assets/grpc/starcoder ./cmd/grpc/starcoder/
backend-assets/grpc/rwkv: backend-assets/grpc go-rwkv/librwkv.a
CGO_LDFLAGS=”$(CGO_LDFLAGS)” C_INCLUDE_PATH=$(shell pwd)/go-rwkv LIBRARY_PATH=$(shell pwd)/go-rwkv
$(GOCMD) build -ldflags “$(LD_FLAGS)” -tags “$(GO_TAGS)” -o backend-assets/grpc/rwkv ./cmd/grpc/rwkv/
backend-assets/grpc/bloomz: backend-assets/grpc bloomz/libbloomz.a
CGO_LDFLAGS=”$(CGO_LDFLAGS)” C_INCLUDE_PATH=$(shell pwd)/bloomz LIBRARY_PATH=$(shell pwd)/bloomz
$(GOCMD) build -ldflags “$(LD_FLAGS)” -tags “$(GO_TAGS)” -o backend-assets/grpc/bloomz ./cmd/grpc/bloomz/
backend-assets/grpc/bert-embeddings: backend-assets/grpc go-bert/libgobert.a
CGO_LDFLAGS=”$(CGO_LDFLAGS)” C_INCLUDE_PATH=$(shell pwd)/go-bert LIBRARY_PATH=$(shell pwd)/go-bert
$(GOCMD) build -ldflags “$(LD_FLAGS)” -tags “$(GO_TAGS)” -o backend-assets/grpc/bert-embeddings ./cmd/grpc/bert-embeddings/
backend-assets/grpc/langchain-huggingface: backend-assets/grpc
$(GOCMD) build -ldflags “$(LD_FLAGS)” -tags “$(GO_TAGS)” -o backend-assets/grpc/langchain-huggingface ./cmd/grpc/langchain-huggingface/
backend-assets/grpc/stablediffusion: backend-assets/grpc go-stable-diffusion/libstablediffusion.a
CGO_LDFLAGS=”$(CGO_LDFLAGS)” C_INCLUDE_PATH=$(shell pwd)/go-stable-diffusion/ LIBRARY_PATH=$(shell pwd)/go-stable-diffusion/
$(GOCMD) build -ldflags “$(LD_FLAGS)” -tags “$(GO_TAGS)” -o backend-assets/grpc/stablediffusion ./cmd/grpc/stablediffusion/
backend-assets/grpc/piper: backend-assets/grpc backend-assets/espeak-ng-data go-piper/libpiper_binding.a
CGO_LDFLAGS=”$(CGO_LDFLAGS)” LIBRARY_PATH=$(shell pwd)/go-piper
$(GOCMD) build -ldflags “$(LD_FLAGS)” -tags “$(GO_TAGS)” -o backend-assets/grpc/piper ./cmd/grpc/piper/
backend-assets/grpc/whisper: backend-assets/grpc whisper.cpp/libwhisper.a
CGO_LDFLAGS=”$(CGO_LDFLAGS)” C_INCLUDE_PATH=$(shell pwd)/whisper.cpp LIBRARY_PATH=$(shell pwd)/whisper.cpp
$(GOCMD) build -ldflags “$(LD_FLAGS)” -tags “$(GO_TAGS)” -o backend-assets/grpc/whisper ./cmd/grpc/whisper/
grpcs: prepare backend-assets/grpc/langchain-huggingface backend-assets/grpc/falcon-ggml backend-assets/grpc/bert-embeddings backend-assets/grpc/falcon backend-assets/grpc/bloomz backend-assets/grpc/llama backend-assets/grpc/gpt4all backend-assets/grpc/dolly backend-assets/grpc/gpt2 backend-assets/grpc/gptj backend-assets/grpc/gptneox backend-assets/grpc/mpt backend-assets/grpc/replit backend-assets/grpc/starcoder backend-assets/grpc/rwkv backend-assets/grpc/whisper $(OPTIONAL_GRPC)
The provided code appears to be a Makefile for building a Go-based application called “local-ai” with various options and dependencies. The Makefile supports various build configurations and targets for different components of the application. Here’s a summary of what the Makefile does:
1. Variables Definition: The Makefile defines several variables, including version numbers, repository URLs, build flags, and library paths. These variables can be overridden during the build process or specified by the user.
2. Targets Definition: The Makefile defines various targets, each corresponding to specific actions, such as building the application, running tests, generating protobuf code, and preparing the required sources and dependencies.
3. Conditional Compilation: The Makefile uses conditional statements (e.g., `ifeq`) to set different build configurations based on the value of specific variables. For example, the build type (`BUILD_TYPE`) determines which GPU acceleration library to use (CUBLAS, OpenBLAS, Metal, or clBLAS).
4. Dependency Download: The Makefile includes targets for cloning and checking out specific versions of external repositories, which are needed for the application (e.g., GPT4ALL, go-ggml-transformers, etc.).
5. Build Targets: The Makefile has build targets for different components of the application, such as GPT4ALL, go-ggllm, go-piper, BERT embeddings, stable diffusion, and others. Each target compiles the respective component into a shared library or binary.
6. Test Targets: The Makefile has test targets for running tests on different parts of the application, such as gpt4all, llama, tts (text-to-speech), and stablediffusion. These tests are grouped under separate labels for easier selection during test execution.
7. GRPC Targets: The Makefile includes targets for building various gRPC services and clients for specific components, like Falcon, Dolly, GPT2, GPTJ, GPTNEOX, MPT, Replit, Starcoder, RWKV, Bloomz, bert-embeddings, langchain-huggingface, and others.
8. Help Target: The Makefile includes a help target that shows available targets and their descriptions.
Overall, this Makefile enables the building and testing of the “local-ai” application with different configurations, including support for GPU acceleration, gRPC services, and various NLP (Natural Language Processing) and AI components.
If you need specific information or assistance with any particular aspect of the Makefile or the “local-ai” application, feel free to ask!
I am trying to build one at a time not the entire project at once
Sure! To build one component at a time, you can specify the target corresponding to that component when running the `make` command. For example, to build the “falcon” component, you can run:
“`bash
make backend-assets/grpc/falcon
“`
Similarly, to build other components like “dolly,” “gpt2,” “gptj,” etc., you can use the respective target names from the Makefile. Just make sure to have the necessary dependencies and prerequisites available before building the specific component.
If you need to clean the build artifacts for a particular component, you can use the `clean` target followed by the specific component target. For example:
“`bash
make clean-backend-assets/grpc/falcon
“`
Again, replace “falcon” with the name of the component you want to clean.
Keep in mind that the dependencies and prerequisites should be available before building individual components. If you encounter any issues related to missing dependencies or build errors, you might need to check the respective component’s build requirements in the Makefile or the associated repository’s documentation.
If you have a specific component in mind and need help with its build process, please let me know the component name, and I’ll provide more detailed instructions.
Not even this one works::: go mod download
touch prepare
CGO_LDFLAGS=”-lcublas -lcudart -L/usr/lib/cuda/lib64/” go run ./
assets.go:5:12: pattern backend-assets/*: no matching files found
make: *** [Makefile:271: run] Error 1
The error message indicates that there are no matching files found for the pattern “backend-assets/*” in the “assets.go” file. This usually happens when the “backend-assets” directory is not present or is empty.
To resolve this issue, make sure that the “backend-assets” directory is available and contains the required assets or files. This directory is typically used to store pre-built or pre-generated assets that are used by the application.
Here are the steps you can take to resolve the issue:
1. Check if the “backend-assets” directory exists in the project directory. If it doesn’t exist, create it manually.
2. Ensure that any necessary assets or files are placed inside the “backend-assets” directory. These assets might include pre-trained models, language resources, or any other files required by the application.
3. After making sure that the “backend-assets” directory is properly set up, run the following commands:
“`bash
go mod download
touch prepare
“`
The first command (`go mod download`) will download the necessary Go modules and dependencies for the project. The second command (`touch prepare`) will create an empty file named “prepare,” which is used by the build process.
4. Once the above commands are executed without any errors, try running the application again with:
“`bash
CGO_LDFLAGS=”-lcublas -lcudart -L/usr/lib/cuda/lib64/” go run ./
“`
If the “backend-assets” directory contains the required files and the dependencies are set up correctly, the application should run without any issues.
If you encounter any further errors or have specific issues related to a particular component of the project, please let me know, and I’ll be happy to assist you further.
What uses backend assets?
The “backend-assets” directory in the given Makefile is used to store pre-built or pre-generated assets that are used by the backend components of the application. These assets are typically required for running specific functionality or features of the application. Here’s a breakdown of the components that use the “backend-assets”:
1. **gpt4all**:
The “gpt4all” component is a directory containing GPT-3 models and related files. The “backend-assets/gpt4all” directory is used to store the built GPT-3 models and their associated dynamic libraries (`.so`, `.dylib`, or `.dll`). These files are required for running the GPT-3 models in the backend.
2. **falcon**:
The “falcon” component is a language model used for natural language processing. The “backend-assets/falcon” directory stores the built Falcon model and its associated dynamic libraries. These files are required for running the Falcon language model in the backend.
3. **llama**:
The “llama” component is a library that provides a Python interface to the GPT-3 models. The “backend-assets/llama” directory is used to store the llama metal library (`.metal`) and other llama-related assets.
4. **dolly**:
The “dolly” component is a language model used for text completion. The “backend-assets/dolly” directory stores the built Dolly model and its associated dynamic libraries. These files are required for running the Dolly language model in the backend.
5. **gpt2**, **gptj**, **gptneox**, **mpt**, **replit**, **starcoder**, **rwkv**, **bloomz**, **bert-embeddings**, **whisper**, **piper**, **langchain-huggingface**, and **stablediffusion**:
These components correspond to various language models and functionality of the application. Each of these components may require specific assets and files that are stored in their respective “backend-assets” directories.
Overall, the “backend-assets” directory is used to centralize the storage of pre-built models and related assets, making it easier to manage and use these assets in the backend code. This directory is essential for running the application’s backend components effectively.
This is where the error code points to: run: prepare ## run local-ai
CGO_LDFLAGS=”$(CGO_LDFLAGS)” $(GOCMD) run ./
The error message “assets.go:5:12: pattern backend-assets/*: no matching files found” indicates that the application is trying to access a file or directory in the “backend-assets” directory but cannot find any matching files. This error typically occurs when the directory is empty or does not contain the expected files.
In the provided Makefile, the “backend-assets” directory is used to store pre-built assets for various components of the application. However, it seems that the required files are not present in the “backend-assets” directory, leading to the error.
Here are a few steps you can take to resolve the issue:
1. Ensure that the “backend-assets” directory is correctly set up and contains the necessary assets for the application.
2. Double-check that the required assets have been generated or copied to the “backend-assets” directory. If not, you may need to build or download the required assets before running the application.
3. Check if any specific make targets are responsible for generating or copying the assets to the “backend-assets” directory. Make sure these targets are executing successfully without any errors.
4. If you are using external scripts or tools to generate assets, ensure that they are functioning correctly and placing the assets in the correct location (i.e., “backend-assets” directory).
5. Verify that any environment variables or configuration settings related to the “backend-assets” directory are correctly set.
Once you have verified that the “backend-assets” directory contains the necessary files and assets, you should be able to run the application without encountering the “no matching files found” error.
GOCMD=go
GOTEST=$(GOCMD) test
GOVET=$(GOCMD) vet
BINARY_NAME=local-ai
It seems you have provided a subset of the Makefile without the entire context, but I’ll try to assist you with the given information.
From the provided Makefile, here are the relevant parts related to building and running the “local-ai” application:
“`makefile
GOCMD=go
GOTEST=$(GOCMD) test
GOVET=$(GOCMD) vet
BINARY_NAME=local-ai
…
run: prepare ## run local-ai
CGO_LDFLAGS=”$(CGO_LDFLAGS)” $(GOCMD) run ./
“`
Here’s a breakdown of what’s happening:
1. `GOCMD=go`: This sets the variable `GOCMD` to “go,” which is the command to invoke the Go compiler.
2. `GOTEST=$(GOCMD) test`: This sets the variable `GOTEST` to “go test,” which is the command to run Go tests.
3. `GOVET=$(GOCMD) vet`: This sets the variable `GOVET` to “go vet,” which is the command to vet (check) Go code for suspicious constructs.
4. `BINARY_NAME=local-ai`: This sets the variable `BINARY_NAME` to “local-ai,” which is the name of the binary to be built for the “local-ai” application.
5. `run: prepare ## run local-ai`: This is a make target named “run” that depends on the target “prepare” (indicated by the “prepare” prerequisite). The “## run local-ai” is a comment indicating the purpose of the target.
6. `CGO_LDFLAGS=”$(CGO_LDFLAGS)” $(GOCMD) run ./`: This is the command to run the “local-ai” application. The `CGO_LDFLAGS` environment variable is set to the value specified in the Makefile. The `$(GOCMD)` expands to the value “go,” and `run` is the “go” command to run Go code. The “./” at the end specifies the current directory as the package to be run.
To build and run the “local-ai” application, you can execute the following commands in your terminal:
1. Build the application (optional if you have not done it before or if there were changes in the code):
“`bash
go build -o $(BINARY_NAME)
“`
This will generate an executable binary named “local-ai.”
2. Run the application:
“`bash
./local-ai
“`
This will execute the “local-ai” binary.
Make sure you are in the correct directory that contains the Makefile and the “local-ai” Go application files before running these commands.
kdir build
cd build && cmake ../ggml.cpp -DGGML_CUBLAS=ON && make VERBOSE=1 ggml && cp -rf src/CMakeFiles/ggml.dir/ggml.c.o ../ggml.o
— The C compiler identification is GNU 11.3.0
— The CXX compiler identification is GNU 11.3.0
— Detecting C compiler ABI info
— Detecting C compiler ABI info – done
— Check for working C compiler: /usr/bin/cc – skipped
— Detecting C compile features
— Detecting C compile features – done
— Detecting CXX compiler ABI info
— Detecting CXX compiler ABI info – done
— Check for working CXX compiler: /usr/bin/c++ – skipped
— Detecting CXX compile features
— Detecting CXX compile features – done
— Found Git: /usr/bin/git (found version “2.34.1”)
— Performing Test CMAKE_HAVE_LIBC_PTHREAD
— Performing Test CMAKE_HAVE_LIBC_PTHREAD – Success
— Found Threads: TRUE
— CMAKE_SYSTEM_PROCESSOR: x86_64
— x86 detected
— Linux detected
— Found CUDAToolkit: /usr/include (found version “11.5.119”)
— cuBLAS found
— The CUDA compiler identification is NVIDIA 11.5.119
— Detecting CUDA compiler ABI info
— Detecting CUDA compiler ABI info – done
— Check for working CUDA compiler: /usr/bin/nvcc – skipped
— Detecting CUDA compile features
— Detecting CUDA compile features – done
— GGML CUDA sources found, configuring CUDA architecture
— x86 detected
— Linux detected
— Configuring done (27.0s)
— Generating done (3.4s)
— Build files have been written to: /mnt/c/SarahOne/SuperAgi/app/localai/go-ggml-transformers/build
make[2]: Entering directory ‘/mnt/c/SarahOne/SuperAgi/app/localai/go-ggml-transformers/build’
/home/gemini/.local/lib/python3.10/site-packages/cmake/data/bin/cmake -S/mnt/c/SarahOne/SuperAgi/app/localai/go-ggml-transformers/ggml.cpp -B/mnt/c/SarahOne/SuperAgi/app/localai/go-ggml-transformers/build –check-build-system CMakeFiles/Makefile.cmake 0
make -f CMakeFiles/Makefile2 ggml
make[3]: Entering directory ‘/mnt/c/SarahOne/SuperAgi/app/localai/go-ggml-transformers/build’
/home/gemini/.local/lib/python3.10/site-packages/cmake/data/bin/cmake -S/mnt/c/SarahOne/SuperAgi/app/localai/go-ggml-transformers/ggml.cpp -B/mnt/c/SarahOne/SuperAgi/app/localai/go-ggml-transformers/build –check-build-system CMakeFiles/Makefile.cmake 0
/home/gemini/.local/lib/python3.10/site-packages/cmake/data/bin/cmake -E cmake_progress_start /mnt/c/SarahOne/SuperAgi/app/localai/go-ggml-transformers/build/CMakeFiles 3
make -f CMakeFiles/Makefile2 src/CMakeFiles/ggml.dir/all
make[4]: Entering directory ‘/mnt/c/SarahOne/SuperAgi/app/localai/go-ggml-transformers/build’
make -f src/CMakeFiles/ggml.dir/build.make src/CMakeFiles/ggml.dir/depend
make[5]: Entering directory ‘/mnt/c/SarahOne/SuperAgi/app/localai/go-ggml-transformers/build’
cd /mnt/c/SarahOne/SuperAgi/app/localai/go-ggml-transformers/build && /home/gemini/.local/lib/python3.10/site-packages/cmake/data/bin/cmake -E cmake_depends “Unix Makefiles” /mnt/c/SarahOne/SuperAgi/app/localai/go-ggml-transformers/ggml.cpp /mnt/c/SarahOne/SuperAgi/app/localai/go-ggml-transformers/ggml.cpp/src /mnt/c/SarahOne/SuperAgi/app/localai/go-ggml-transformers/build /mnt/c/SarahOne/SuperAgi/app/localai/go-ggml-transformers/build/src /mnt/c/SarahOne/SuperAgi/app/localai/go-ggml-transformers/build/src/CMakeFiles/ggml.dir/DependInfo.cmake –color=
make[5]: Leaving directory ‘/mnt/c/SarahOne/SuperAgi/app/localai/go-ggml-transformers/build’
make -f src/CMakeFiles/ggml.dir/build.make src/CMakeFiles/ggml.dir/build
make[5]: Entering directory ‘/mnt/c/SarahOne/SuperAgi/app/localai/go-ggml-transformers/build’
[ 33%] Building C object src/CMakeFiles/ggml.dir/ggml.c.o
cd /mnt/c/SarahOne/SuperAgi/app/localai/go-ggml-transformers/build/src && /usr/bin/cc -DGGML_USE_CUBLAS -I/mnt/c/SarahOne/SuperAgi/app/localai/go-ggml-transformers/ggml.cpp/src/. -I/mnt/c/SarahOne/SuperAgi/app/localai/go-ggml-transformers/ggml.cpp/src/../include -I/mnt/c/SarahOne/SuperAgi/app/localai/go-ggml-transformers/ggml.cpp/src/../include/ggml -Wall -Wextra
-Wpedantic -Wshadow -Wcast-qual -Wstrict-prototypes
-Wpointer-arith -Wdouble-promotion -Wno-unused-function -Werror=vla -mavx -mavx2 -mfma -mf16c -msse3 -O3 -DNDEBUG -std=gnu11 -MD -MT src/CMakeFiles/ggml.dir/ggml.c.o -MF CMakeFiles/ggml.dir/ggml.c.o.d -o CMakeFiles/ggml.dir/ggml.c.o -c /mnt/c/SarahOne/SuperAgi/app/localai/go-ggml-transformers/ggml.cpp/src/ggml.c
[ 66%] Building CUDA object src/CMakeFiles/ggml.dir/ggml-cuda.cu.o
cd /mnt/c/SarahOne/SuperAgi/app/localai/go-ggml-transformers/build/src && /usr/bin/nvcc -forward-unknown-to-host-compiler -DGGML_USE_CUBLAS –options-file CMakeFiles/ggml.dir/includes_CUDA.rsp -O3 -DNDEBUG -std=c++11 -MD -MT src/CMakeFiles/ggml.dir/ggml-cuda.cu.o -MF CMakeFiles/ggml.dir/ggml-cuda.cu.o.d -x cu -c /mnt/c/SarahOne/SuperAgi/app/localai/go-ggml-transformers/ggml.cpp/src/ggml-cuda.cu -o CMakeFiles/ggml.dir/ggml-cuda.cu.o
[100%] Linking CUDA static library libggml.a
It appears that the build process for the “ggml” application using CMake and CUDA has been completed successfully. The output indicates that the C and CUDA sources have been compiled, and a static library named “libggml.a” has been created.
Now, you mentioned that you want to use this library with Go code. To use a C/C++ library in Go, you will need to create a Go wrapper around the C/C++ functions. The process involves using cgo to interface with the C functions from Go. Here’s a general outline of what you need to do:
1. **Create C Wrappers:**
– Write C wrapper functions for the functionality you want to use from “libggml.a.” These C functions will call the corresponding functions in the library.
2. **Create Go Wrappers:**
– Write Go wrapper functions that use cgo to call the C functions. These Go functions will be used by your Go code to interact with the C library.
3. **Build and Link:**
– Build the C code, creating a shared object (`.so`) or dynamic link library (`.dll`).
– Build the Go code, ensuring that cgo links to the C shared object.
Since the actual code and functions in “libggml.a” are not visible from the information provided, I’ll provide a simplified example to illustrate the process.
Assuming you have the C function `int ggml_add(int a, int b)` defined in “libggml.a” that performs addition, you would create the following C and Go wrappers:
**Step 1: Create C Wrapper**
Create a C header file “ggml_c_wrapper.h” containing the C function prototype:
“`c
// ggml_c_wrapper.h
#ifndef GGML_C_WRAPPER_H
#define GGML_C_WRAPPER_H
#ifdef __cplusplus
extern “C” {
#endif
int ggml_add(int a, int b);
#ifdef __cplusplus
}
#endif
#endif // GGML_C_WRAPPER_H
“`
**Step 2: Create Go Wrapper**
Create a Go file “ggml.go” that uses cgo to interface with the C function:
“`go
// ggml.go
package main
/*
#cgo CFLAGS: -I./path/to/header
#cgo LDFLAGS: -L./path/to/library -lggml
#include “ggml_c_wrapper.h”
*/
import “C”
// Add is a Go wrapper function for ggml_add.
func Add(a, b int) int {
return int(C.ggml_add(C.int(a), C.int(b)))
}
“`
**Step 3: Build and Use the Library**
To build and use the library, you can use the following commands:
“`bash
# Build the C shared object from libggml.a (example; actual commands may differ)
gcc -shared -o libggml.so -L/path/to/library -lggml
# Build the Go code using cgo
go build -o your_program ggml.go main.go
# Run your Go program
./your_program
“`
Remember to replace `/path/to/header` and `/path/to/library` with the actual paths where “ggml_c_wrapper.h” and “libggml.a” are located, respectively.
Please note that this is a simplified example, and the actual process may vary based on the functions and datatypes present in “libggml.a.” You’ll need to adapt the wrapper code accordingly to match the function signatures and data types in the library.
replit.cpp:65:31: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘__gnu_cxx::__alloc_traits<std::allocator, long unsigned int>::value_type’ {aka ‘long unsigned int’} [-Wformat=]
65 | printf(“%s: token[%d] = %6dn”, __func__, i, embd_inp[i]);
| ~~^
| |
| int
| %6ld
make: *** [Makefile:386: backend-assets/grpc/falcon-ggml] Error 2
(base) gemini@DESKTOP-UNG8TH9:/mnt/c/SarahOne/SuperAgi/app/localai$
The warning you encountered is related to a format mismatch in the `printf` function. The `%d` format specifier expects an argument of type `int`, but in your case, the argument provided (`embd_inp[i]`) has the type `long unsigned int`, which corresponds to `%ld` format specifier.
To fix this warning, you need to update the format specifier in the `printf` statement from `%d` to `%ld`. Additionally, it’s a good practice to cast the argument to the appropriate type to ensure that the format specifier matches the actual data type. Here’s the corrected `printf` statement:
“`cpp
printf(“%s: token[%d] = %6ldn”, __func__, i, (long int)embd_inp[i]);
“`
By using `%ld` for `long int` and `(long int)` type-casting for `embd_inp[i]`, the warning should be resolved.
However, please note that this change only addresses the warning related to the format mismatch. If there are other issues or errors in your code, you’ll need to address them separately. Make sure to review the surrounding code to ensure proper handling of the data types and other potential issues.
[Makefile:386: backend-assets/grpc/falcon-ggml] Error 2
The error you are encountering is a build error, and it seems to be related to the `backend-assets/grpc/falcon-ggml` target in your Makefile. Error 2 usually indicates that there was an issue during the build process, and the specific error message should provide more information about what went wrong.
To investigate and resolve this error, follow these steps:
1. Check the complete error message: Look for the detailed error message that occurred during the build process. It should provide more context and information about the specific problem.
2. Inspect the Makefile: Go to line 386 in your Makefile (backend-assets/grpc/falcon-ggml) and see what command or actions are being executed there. This will help you understand what’s happening and what could be causing the error.
3. Look for missing dependencies: The error could be due to missing dependencies or files required for the build process. Make sure all necessary dependencies are properly installed and accessible.
4. Check for any changes in the code: If you made any recent changes to the codebase or the build configuration, they might be the cause of the error. Review your changes and make sure they are correct.
5. Verify environment settings: Ensure that your build environment is properly configured and all required tools and libraries are available.
6. Check the build log: If available, review the complete build log or verbose output to identify any issues or error messages that occurred during the build process.
7. Search for similar issues: If the error message is not clear or you are unsure about its cause, try searching for similar issues or error messages online. Others may have encountered and resolved similar problems.
8. Seek help from the community: If you are still unable to resolve the issue, consider seeking help from online developer communities, forums, or the project’s support channels. Other developers with experience in the project might be able to provide valuable insights.
Keep in mind that without the specific error message and access to your code, it’s challenging to pinpoint the exact cause of the error. So, make sure to examine the error messages, the related parts of the Makefile, and the build process to troubleshoot the issue effectively.
/usr/bin/ld: go-ggml-transformers/libtransformers.a(ggml-cuda.o): in function `__sti____cudaRegisterAll()’:
tmpxft_000053a2_00000000-6_ggml-cuda.cudafe1.cpp:(.text.startup+0xd): undefined reference to `__cudaRegisterFatBinary’
/usr/bin/ld: tmpxft_000053a2_00000000-6_ggml-cuda.cudafe1.cpp:(.text.startup+0x41): undefined reference to `__cudaRegisterFunction’
/usr/bin/ld: tmpxft_000053a2_00000000-6_ggml-cuda.cudafe1.cpp:(.text.startup+0x6f): undefined reference to `__cudaRegisterFunction’
/usr/bin/ld: tmpxft_000053a2_00000000-6_ggml-cuda.cudafe1.cpp:(.text.startup+0x9d): undefined reference to `__cudaRegisterFunction’
/usr/bin/ld: tmpxft_000053a2_00000000-6_ggml-cuda.cudafe1.cpp:(.text.startup+0xcb): undefined reference to `__cudaRegisterFunction’
/usr/bin/ld: tmpxft_000053a2_00000000-6_ggml-cuda.cudafe1.cpp:(.text.startup+0xf9): undefined reference to `__cudaRegisterFunction’
/usr/bin/ld: go-ggml-transformers/libtransformers.a(ggml-cuda.o):tmpxft_000053a2_00000000-6_ggml-cuda.cudafe1.cpp:(.text.startup+0x127): more undefined references to `__cudaRegisterFunction’ follow
/usr/bin/ld: go-ggml-transformers/libtransformers.a(ggml-cuda.o): in function `__sti____cudaRegisterAll()’:
tmpxft_000053a2_00000000-6_ggml-cuda.cudafe1.cpp:(.text.startup+0x63f): undefined reference to `__cudaRegisterFatBinaryEnd’
collect2: error: ld returned 1 exit status
# github.com/go-skynet/go-ggml-transformers.cpp
In file included from replit.cpp:21:
ggml.cpp/examples/replit/main.cpp: In function ‘bool replit_model_load(const string&, replit_model&, replit_tokenizer&)’:
ggml.cpp/examples/replit/main.cpp:345:56: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 4 has type ‘long int’ [-Wformat=]
345 | printf(“%s: memory_size = %8.2f MB, n_mem = %lldn”, __func__, memory_size / 1024.0 / 1024.0, n_mem);
| ~~~^ ~~~~~
| | |
| long long int long int
| %ld
replit.cpp: In function ‘int replit_predict(void*, void*, char*)’:
replit.cpp:65:31: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘__gnu_cxx::__alloc_traits<std::allocator, long unsigned int>::value_type’ {aka ‘long unsigned int’} [-Wformat=]
65 | printf(“%s: token[%d] = %6dn”, __func__, i, embd_inp[i]);
| ~~^
| |
| int
| %6ld
make: *** [Makefile:386: backend-assets/grpc/falcon-ggml] Error 2
The error messages you provided indicate issues with CUDA registration symbols in the `libtransformers.a` library. These errors typically occur when there are mismatches or issues with the CUDA version or configuration during the build process.
To resolve the CUDA-related build errors, consider the following steps:
1. Check CUDA version compatibility: Make sure that the version of CUDA used to compile the `libtransformers.a` library is compatible with the version of CUDA used in your project. Ensure that you have the correct CUDA version installed on your system.
2. Verify CUDA path and library inclusion: Ensure that the necessary CUDA include paths and libraries are properly set in the build configuration. Check if the `-L` flag pointing to the CUDA library path and the `-lcudart` and `-lcublas` flags are correctly provided during the build process.
3. Check the CUDA compilation settings: Verify that the CUDA files (`ggml-cuda.cu` in this case) are being compiled with the appropriate CUDA compiler (nvcc) and that the correct compilation flags are used (such as `-arch`, which specifies the GPU architecture).
4. Rebuild `libtransformers.a`: If the `libtransformers.a` library was precompiled and provided to you, consider rebuilding it from the source code using the same CUDA version and settings as your project.
5. Ensure proper linking order: Make sure that the `libtransformers.a` library is linked before the main binary during the linking step. The linker processes the files in the order they are specified, so the library should come before any code that uses it.
6. Check dependencies: Ensure that there are no missing dependencies or unresolved symbols in the `libtransformers.a` library.
7. Check for conflicting CUDA installations: If you have multiple CUDA installations on your system, there might be conflicts. Ensure that you are using the correct one for your project.
8. Check the project’s documentation: If the project you are trying to build has specific CUDA-related build instructions or requirements, consult its documentation or README file for guidance.
9. Clean and rebuild: Sometimes, stale build artifacts can cause issues. Try cleaning the build directory thoroughly and then rebuild the project.
Remember to verify each step carefully, as CUDA-related build issues can be complex and require attention to detail. If the problem persists, consider seeking help from the project’s community or support channels, as they might have encountered and resolved similar issues before.