Skip to content

Commit

Permalink
Intercept ocl environment variables before running
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardozcm committed Jan 21, 2025
1 parent 412bfd6 commit 164307c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
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
27 changes: 27 additions & 0 deletions python/llm/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,30 @@ 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)
self.copy_activate_script()

def copy_activate_script(self):
conda_prefix = os.environ.get('CONDA_PREFIX')
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 +413,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

0 comments on commit 164307c

Please sign in to comment.