Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Intercept ocl environment variables before running #12726

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions python/llm/scripts/activate-unset-ocl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

unset OCL_ICD_VENDORS
28 changes: 28 additions & 0 deletions python/llm/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,31 @@ def download_libs(url: str, change_permission=False):
if change_permission:
os.chmod(libso_file, 0o775)

from setuptools.command.install import install

class IPEXLLMInstallCommand(install):
def run(self):
install.run(self)
if not platform.platform().startswith('Windows'):
self.copy_activate_script()

def copy_activate_script(self):
conda_prefix = os.environ.get('CONDA_PREFIX')
Copy link
Contributor

@Oscilloscope98 Oscilloscope98 Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if for Windows and users without conda?

if conda_prefix:
activate_d_dir = os.path.join(conda_prefix, 'etc', 'conda', 'activate.d')
if not os.path.exists(activate_d_dir):
os.makedirs(activate_d_dir)
script_src = os.path.join(os.path.dirname(__file__), 'scripts', 'activate-unset-ocl.sh')
script_dst = os.path.join(activate_d_dir, 'activate-unset-ocl.sh')
self.copy_file(script_src, script_dst)
else:
print("CONDA_PREFIX environment variable is not set. Are you sure you're in a conda environment?")

def copy_file(self, src, dst):
import shutil
shutil.copy(src, dst)
print(f"Copied {src} to {dst}")


def setup_package():
package_data = {}
Expand Down Expand Up @@ -389,6 +414,9 @@ def setup_package():
'Linux': ['src/ipex_llm/cli/llm-cli', 'src/ipex_llm/cli/llm-chat', 'scripts/ipex-llm-init'],
'Windows': ['src/ipex_llm/cli/llm-cli.ps1', 'src/ipex_llm/cli/llm-chat.ps1', 'scripts/ipex-llm-init.bat'],
}[platform_name],
cmdclass={
'install': IPEXLLMInstallCommand,
},
platforms=['windows']
)

Expand Down
Loading